Skip to content

Commit

Permalink
fix: inaccurate error message when pull not required
Browse files Browse the repository at this point in the history
  • Loading branch information
ViscousPot committed Jan 24, 2025
1 parent ed609ff commit 140ba05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/src/main/java/com/viscouspot/gitsync/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ class MainActivity : AppCompatActivity() {
{
networkRequired(applicationContext)
},
) { }
null
)

if (result == false) {
makeToast(applicationContext, getString(R.string.pull_failed))
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/viscouspot/gitsync/util/GitManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,12 @@ class GitManager(private val context: Context, private val settingsManager: Sett
return false
}

fun downloadChanges(userStorageUri: Uri, scheduleNetworkSync: () -> Unit, onSync: () -> Unit): Boolean? {
fun downloadChanges(userStorageUri: Uri, scheduleNetworkSync: () -> Unit, onSync: (() -> Unit)?): Boolean? {
if (conditionallyScheduleNetworkSync(scheduleNetworkSync)) {
return null
}
try {
var returnResult: Boolean? = false
var returnResult: Boolean? = onSync == null
log(LogType.PullFromRepo, "Getting local directory")
val repo = FileRepository("${Helper.getPathFromUri(context, userStorageUri)}/${context.getString(R.string.git_path)}")
val git = Git(repo)
Expand All @@ -262,7 +262,7 @@ class GitManager(private val context: Context, private val settingsManager: Sett

if (!fetchResult.trackingRefUpdates.isEmpty() || !localHead.equals(remoteHead)) {
log(LogType.PullFromRepo, "Pulling changes")
onSync.invoke()
onSync?.invoke()
val result = git.pull().apply {
applyCredentials(this)
setRemote(settingsManager.getRemote())
Expand Down

0 comments on commit 140ba05

Please sign in to comment.