Skip to content

Commit

Permalink
Add application plugin for distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
goodwinnk committed Apr 3, 2018
1 parent 31d6beb commit 8ea1085
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
apply plugin: 'application'
mainClassName = "nk.patchsets.git.general.Bunch"

buildscript {
ext.kotlin_version = '1.2.30'
ext.kotlin_target = '1.8'
Expand All @@ -13,7 +16,7 @@ buildscript {

allprojects {
group 'nk'
version '0.1-SNAPSHOT'
version '0.0.1'

ext.applyKotlin = {
apply plugin: 'kotlin'
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
rootProject.name = 'patchsets'
rootProject.name = 'bunch'

35 changes: 35 additions & 0 deletions src/main/kotlin/nk/patchsets/git/general.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@file:Suppress("PackageDirectoryMismatch")
@file:JvmName("Bunch")

package nk.patchsets.git.general

import nk.patchsets.git.cp.cherryPick
import nk.patchsets.git.restore.restore

fun main(args: Array<String>) {
if (args.isEmpty()) {
System.err.println("""
Usage: cp|restore <args>
cp - for commits cherry pick
restore - for restore branch state
Example:
<program> restore C:/Projects/kotlin 173->172->171->as30
""".trimIndent())

return
}

val command = args[0]
val commandArgs = args.sliceArray(1..args.size)

when (command) {
"cp" -> cherryPick(commandArgs)
"restore" -> restore(commandArgs)
else -> {
System.err.println("Unknown command: $command")
return
}
}
}
8 changes: 6 additions & 2 deletions src/main/kotlin/nk/patchsets/git/patch-cherry-pick.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:Suppress("PackageDirectoryMismatch")
@file:JvmName("PatchCherryPick")
@file:JvmName("BunchCherryPick")

package nk.patchsets.git.cp

Expand Down Expand Up @@ -28,6 +28,10 @@ private val kotlinSettings = Settings(
)

fun main(args: Array<String>) {
cherryPick(args)
}

fun cherryPick(args: Array<String>) {
if (args.size != 4) {
System.err.println("""
Usage: <git-path> <since-ref> <until-ref> <suffix>
Expand All @@ -45,7 +49,7 @@ fun main(args: Array<String>) {
}

val settings = Settings(args[0], args[1], args[2], args[3])
with (settings) {
with(settings) {
val commits = readCommits(gitPath, branch, untilHash)

for (commit in commits.reversed()) {
Expand Down
10 changes: 7 additions & 3 deletions src/main/kotlin/nk/patchsets/git/restore-branch.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@file:Suppress("PackageDirectoryMismatch")
@file:JvmName("PatchRestore")
@file:JvmName("BunchRestore")

package nk.patchsets.git.restore

Expand All @@ -21,6 +21,10 @@ val kotlinSettings = Settings(
)

fun main(args: Array<String>) {
restore(args)
}

fun restore(args: Array<String>) {
if (args.size != 3 && args.size != 2) {
System.err.println("""
Usage: <git-path> <branches-rule> <commit-title>?
Expand All @@ -39,7 +43,7 @@ fun main(args: Array<String>) {

val settings = Settings(
repoPath = args[0],
rule = args[2],
rule = args[1],
commitTitle = args.getOrElse(2, { "==== switch ====" })
)

Expand All @@ -59,7 +63,7 @@ fun main(args: Array<String>) {
val affectedOriginFiles: Set<File> = root
.walkTopDown()
.filter { child -> child.extension in donorExtensionsPrioritized }
.mapTo(HashSet(), { child -> File(child.parentFile, child.nameWithoutExtension)})
.mapTo(HashSet(), { child -> File(child.parentFile, child.nameWithoutExtension) })

for (originFile in affectedOriginFiles) {
val originFileModificationType: ChangeType
Expand Down

0 comments on commit 8ea1085

Please sign in to comment.