fix(git): init clone
This commit is contained in:
parent
8d1472b5a7
commit
bbea101acd
1 changed files with 7 additions and 4 deletions
|
@ -11,13 +11,15 @@ class GitActions(
|
||||||
private val context: Context
|
private val context: Context
|
||||||
) {
|
) {
|
||||||
private val cloneFolder = context.filesDir.resolve("popequer")
|
private val cloneFolder = context.filesDir.resolve("popequer")
|
||||||
private val myCommitter = "sos" to "example@example.org"
|
private val myCommitter = "Mobile Sandbox" to "example@example.org"
|
||||||
private val credentials = UsernamePasswordCredentialsProvider(
|
private val credentials = UsernamePasswordCredentialsProvider(
|
||||||
"popequer-mobile-sandbox",
|
"popequer-mobile-sandbox",
|
||||||
"armament opals stupidest proud classmates"
|
"armament opals stupidest proud classmates"
|
||||||
)
|
)
|
||||||
private val git by lazy {
|
private lateinit var git: Git
|
||||||
runCatching {
|
|
||||||
|
fun cloneOrInit() {
|
||||||
|
git = runCatching {
|
||||||
Git.open(cloneFolder)
|
Git.open(cloneFolder)
|
||||||
}.getOrElse {
|
}.getOrElse {
|
||||||
cloneFolder.deleteRecursively()
|
cloneFolder.deleteRecursively()
|
||||||
|
@ -29,8 +31,9 @@ class GitActions(
|
||||||
.call()
|
.call()
|
||||||
} ?: throw IllegalStateException("Failed to open git repository")
|
} ?: throw IllegalStateException("Failed to open git repository")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun trigger() {
|
fun trigger() {
|
||||||
|
cloneOrInit()
|
||||||
|
|
||||||
val hash = System.currentTimeMillis().hashCode().absoluteValue.toString(16)
|
val hash = System.currentTimeMillis().hashCode().absoluteValue.toString(16)
|
||||||
val myFile = cloneFolder.resolve("my_file_$hash.txt").also {
|
val myFile = cloneFolder.resolve("my_file_$hash.txt").also {
|
||||||
it.writeText("$hash ! ")
|
it.writeText("$hash ! ")
|
||||||
|
|
Loading…
Reference in a new issue