Skip to content

Commit bdebf84

Browse files
committed
Merge branch 'master' of vp-git:ViscousPotential/GitSync
2 parents 5c8a196 + b7471fd commit bdebf84

File tree

13 files changed

+95
-62
lines changed

13 files changed

+95
-62
lines changed

.maestro/auth/flows/https/start.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ appId: com.viscouspot.gitsync
44
- runFlow: ../assert.yaml
55
- runFlow:
66
when:
7-
notVisible: "HTTP/S (BETA)"
7+
notVisible: "HTTP/S"
88
commands:
99
- tapOn:
1010
id: "gitProviderSpinner"
11-
- assertVisible: "HTTP/S (BETA)"
12-
- tapOn: "HTTP/S (BETA)"
11+
- assertVisible: "HTTP/S"
12+
- tapOn: "HTTP/S"

.maestro/auth/flows/ssh/start.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ appId: com.viscouspot.gitsync
44
- runFlow: ../assert.yaml
55
- runFlow:
66
when:
7-
notVisible: "SSH (BETA)"
7+
notVisible: "SSH"
88
commands:
99
- tapOn:
1010
id: "gitProviderSpinner"
11-
- assertVisible: "SSH (BETA)"
12-
- tapOn: "SSH (BETA)"
11+
- assertVisible: "SSH"
12+
- tapOn: "SSH"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
<br />
2424
<p align="center">
25-
<a href="https://github.com/ViscousPot/GitSync/blob/master/Documentation.md">Documentation</a>
25+
<a href="https://github.com/ViscousPot/GitSync/wiki">Documentation</a>
2626
</p>
2727
<br />
2828

app/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId = "com.viscouspot.gitsync"
1313
minSdk = 21
1414
targetSdk = 34
15-
versionCode = 1701
16-
versionName = "1.701"
15+
versionCode = 1702
16+
versionName = "1.702"
1717

1818
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1919
vectorDrawables {
@@ -83,4 +83,4 @@ dependencies {
8383
androidTestImplementation(libs.androidx.ui.test.junit4)
8484
debugImplementation(libs.androidx.ui.tooling)
8585
debugImplementation(libs.androidx.ui.test.manifest)
86-
}
86+
}

app/src/main/java/com/viscouspot/gitsync/GitSyncService.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ class GitSyncService : Service() {
6868
when (intent.action) {
6969
MERGE -> {
7070
log(LogType.ToServiceCommand, "Merge")
71-
merge(repoIndex)
71+
val commitMessage = intent.getStringExtra("commitMessage") ?: ""
72+
merge(repoIndex, commitMessage)
7273
}
7374
FORCE_SYNC -> {
7475
log(LogType.ToServiceCommand, "Force Sync")
@@ -233,7 +234,7 @@ class GitSyncService : Service() {
233234
}
234235
}
235236

236-
private fun merge(repoIndex: Int) {
237+
private fun merge(repoIndex: Int, commitMessage: String) {
237238
val settingsManager = SettingsManager(this, repoIndex)
238239
val gitManager = GitManager(this, settingsManager)
239240

@@ -251,7 +252,9 @@ class GitSyncService : Service() {
251252
getString(R.string.resolving_merge),
252253
)
253254
}
254-
}
255+
},
256+
null,
257+
commitMessage
255258
)
256259

257260
when (pushResult) {

app/src/main/java/com/viscouspot/gitsync/MainActivity.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,16 @@ class MainActivity : AppCompatActivity() {
361361
return@Pair
362362
}
363363
val job = CoroutineScope(Dispatchers.Default).launch {
364-
gitManager.downloadChanges(
364+
val result = gitManager.downloadChanges(
365365
gitDirUri,
366366
{
367367
networkRequired(applicationContext)
368368
},
369369
) { }
370370

371+
if (result == false) {
372+
makeToast(applicationContext, getString(R.string.pull_failed))
373+
}
371374
}
372375

373376
job.invokeOnCompletion {

app/src/main/java/com/viscouspot/gitsync/ui/adapter/SpinnerIconPrefixAdapter.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ class SpinnerIconPrefixAdapter(private val context: Context, private val items:
2626
val textView = view.findViewById<TextView>(R.id.gitProviderName)
2727
val item = items[position]
2828
textView.text = item.first
29-
if (listOf("HTTP/S", "SSH").contains(item.first)) {
30-
textView.text = context.getString(R.string.beta).format(item.first)
31-
}
3229
textView.gravity = Gravity.CENTER_VERTICAL
3330

3431
if (item.second == null) {

app/src/main/java/com/viscouspot/gitsync/ui/dialog/MergeConflictDialog.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import android.content.res.ColorStateList
66
import android.net.Uri
77
import android.view.View
88
import android.webkit.MimeTypeMap
9+
import android.widget.EditText
910
import android.widget.HorizontalScrollView
1011
import androidx.core.content.ContextCompat
1112
import androidx.core.content.FileProvider
@@ -31,14 +32,16 @@ class MergeConflictDialog(private val context: Context, private val repoIndex: I
3132
return SNAP_TO_START
3233
}
3334
}
35+
private lateinit var syncMessageInput: EditText
3436

3537
override fun onStart() {
3638
super.onStart()
3739
setContentView(R.layout.dialog_merge_conflict)
3840

3941
val conflicts = gitManager.getConflicting(settingsManager.getGitDirUri())
4042
if (conflicts.isEmpty()) return
41-
43+
44+
syncMessageInput = findViewById(R.id.syncMessageInput) ?: return
4245
val conflictEditor = findViewById<HorizontalScrollView>(R.id.conflictEditor) ?: return
4346
val conflictEditorInput = findViewById<RecyclerView>(R.id.conflictEditorInput) ?: return
4447
val fileName = findViewById<MaterialButton>(R.id.fileName) ?: return
@@ -148,6 +151,7 @@ class MergeConflictDialog(private val context: Context, private val repoIndex: I
148151
val forceSyncIntent = Intent(context, GitSyncService::class.java)
149152
forceSyncIntent.setAction(GitSyncService.MERGE)
150153
forceSyncIntent.putExtra("repoIndex", repoIndex)
154+
forceSyncIntent.putExtra("commitMessage", syncMessageInput.text.toString())
151155
context.startService(forceSyncIntent)
152156
}
153157

app/src/main/java/com/viscouspot/gitsync/util/GitManager.kt

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class GitManager(private val context: Context, private val settingsManager: Sett
236236
return null
237237
}
238238

239-
if (repo.isBare || repo.resolve(Constants.HEAD) == null) return false
239+
if (repo.resolve(Constants.HEAD) == null) return false
240240

241241
val localHead: ObjectId = repo.resolve(Constants.HEAD)
242242
val remoteHead: ObjectId = repo.resolve(Constants.FETCH_HEAD)
@@ -399,52 +399,56 @@ class GitManager(private val context: Context, private val settingsManager: Sett
399399
logStatus(git)
400400
val uncommitted = filePaths ?: getUncommittedFilePaths(userStorageUri, git)
401401

402-
if (uncommitted.isNotEmpty()) {
403-
onSync.invoke()
404-
405-
log(LogType.PushToRepo, "Adding Files to Stage")
402+
if (uncommitted.isEmpty()) {
403+
log(LogType.PushToRepo, "Closing repository")
404+
closeRepo(repo)
405+
return false
406+
}
406407

407-
// Adds all uncommitted and untracked files to the index for staging.
408-
git.add().apply {
409-
uncommitted.forEach { addFilepattern(it) }
410-
}.call()
408+
onSync.invoke()
411409

412-
// Updates the index to reflect changes in already tracked files, removing deleted files without adding untracked files.
413-
git.add().apply {
414-
uncommitted.forEach { addFilepattern(it) }
415-
isUpdate = true
416-
}.call()
410+
log(LogType.PushToRepo, "Adding Files to Stage")
417411

418-
log(LogType.PushToRepo, "Getting current time")
412+
// Adds all uncommitted and untracked files to the index for staging.
413+
git.add().apply {
414+
uncommitted.forEach { addFilepattern(it) }
415+
}.call()
419416

420-
val formattedDate: String = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).apply {
421-
timeZone = TimeZone.getTimeZone("UTC")
422-
}.format(Date())
417+
// Updates the index to reflect changes in already tracked files, removing deleted files without adding untracked files.
418+
git.add().apply {
419+
uncommitted.forEach { addFilepattern(it) }
420+
isUpdate = true
421+
}.call()
423422

424-
log(LogType.PushToRepo, "Committing changes")
425-
val config: StoredConfig = git.repository.config
423+
log(LogType.PushToRepo, "Getting current time")
426424

427-
var committerEmail: String? = settingsManager.getAuthorEmail()
428-
if (committerEmail == null || committerEmail == "") {
429-
committerEmail = config.getString("user", null, "email")
430-
}
425+
val formattedDate: String = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).apply {
426+
timeZone = TimeZone.getTimeZone("UTC")
427+
}.format(Date())
431428

432-
var committerName: String? = settingsManager.getAuthorName()
433-
if (committerName == null || committerName == "") {
434-
committerName = config.getString("user", null, "name")
435-
}
436-
if (committerName == null || committerName == "") {
437-
committerName = settingsManager.getGitAuthCredentials().first
438-
}
429+
log(LogType.PushToRepo, "Committing changes")
430+
val config: StoredConfig = git.repository.config
439431

440-
git.commit().apply {
441-
setCommitter(committerName, committerEmail ?: "")
442-
message = if (!syncMessage.isNullOrEmpty()) syncMessage else settingsManager.getSyncMessage().format(formattedDate)
443-
}.call()
432+
var committerEmail: String? = settingsManager.getAuthorEmail()
433+
if (committerEmail == null || committerEmail == "") {
434+
committerEmail = config.getString("user", null, "email")
435+
}
444436

445-
returnResult = true
437+
var committerName: String? = settingsManager.getAuthorName()
438+
if (committerName == null || committerName == "") {
439+
committerName = config.getString("user", null, "name")
440+
}
441+
if (committerName == null || committerName == "") {
442+
committerName = settingsManager.getGitAuthCredentials().first
446443
}
447444

445+
git.commit().apply {
446+
setCommitter(committerName, committerEmail ?: "")
447+
message = if (!syncMessage.isNullOrEmpty()) syncMessage else settingsManager.getSyncMessage().format(formattedDate)
448+
}.call()
449+
450+
returnResult = true
451+
448452
if (conditionallyScheduleNetworkSync(scheduleNetworkSync)) {
449453
return null
450454
}

app/src/main/java/com/viscouspot/gitsync/util/Logger.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ object Logger {
7575

7676
private fun addToLastLogs(type: LogType, message: String) {
7777
lastLogs.add(Pair(type, message))
78-
while (lastLogs.size > 50) {
78+
while (lastLogs.size > 10) {
7979
lastLogs.removeAt(0)
8080
}
8181
}
@@ -144,4 +144,4 @@ $lastLogsString
144144

145145
return intent
146146
}
147-
}
147+
}

0 commit comments

Comments
 (0)