Skip to content

Instantly share code, notes, and snippets.

@kikuchy
Created August 27, 2016 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kikuchy/cf0b5a0bcd934a27a28d2e31cf2e1587 to your computer and use it in GitHub Desktop.
Save kikuchy/cf0b5a0bcd934a27a28d2e31cf2e1587 to your computer and use it in GitHub Desktop.
fun main(args: Array<String>) {
val tmpPath = File(System.getProperty("java.io.tmpdir")).toPath()
val fileAttribute = PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString("rwxrwx---"))
val tmpDir = Files.createTempDirectory(
tmpPath,
"hogehoge",
fileAttribute
).toFile()
val git = Git.
init().
setDirectory(tmpDir).
call()
git.remoteAdd().apply {
setName("origin")
setUri(URIish("https://github.com/kikuchy/line-sender.git"))
}.call()
git.fetch().apply {
setTagOpt(TagOpt.FETCH_TAGS)
}.call()
git.checkout().setName(git.tagList().call()[0].objectId.name).call()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment