Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always dirty #81

Open
benkeil opened this issue Apr 3, 2023 · 3 comments · May be fixed by #82
Open

always dirty #81

benkeil opened this issue Apr 3, 2023 · 3 comments · May be fixed by #82

Comments

@benkeil
Copy link

benkeil commented Apr 3, 2023

The branch is clean.

output of git log

485155d (HEAD -> main, origin/main, origin/HEAD) chore: add env to check step
c8a8891 chore: use dependabot plugin
d9f7bab chore: update README
8e120c3 (tag: v1.0.10) chore(release): 1.0.10 [skip ci]

output of ./gradlew showVersion

> Task :showVersion
Version: 1.0.10-dirty-SNAPSHOT

Happens on my Mac, my colleagues with Linux don't face the problem.

@benkeil
Copy link
Author

benkeil commented Apr 4, 2023

After a new build

output of git log

bcabb17 (HEAD -> main, tag: v1.0.11, origin/main) chore(release): 1.0.11 [skip ci]

output of ./gradlew showVersion

> Task :showVersion
Version: 1.0.11-dirty-SNAPSHOT

@benkeil
Copy link
Author

benkeil commented Apr 4, 2023

and the configuration:

semver {
  snapshotSuffix = "SNAPSHOT" // (default) appended if the commit is without a release tag
  dirtyMarker = "dirty" // (default) appended if there are uncommitted changes
  initialVersion = "0.1.22" // (default) initial version in semantic versioning
  tagPrefix = "v" // (default) each project can have its own tags identified by a unique prefix.
  tagType = io.wusa.TagType.LIGHTWEIGHT // (default) options are Annotated or Lightweight
  branches { // list of branch configurations
    branch {
      regex = ".+" // regex for the branch you want to configure, put this one last
      incrementer = "NO_VERSION_INCREMENTER" // (default) version incrementer
      formatter = Transformer {
        "${semver.info.version.major}.${semver.info.version.minor}.${semver.info.version.patch}"
      }
    }
  }
}

@benkeil
Copy link
Author

benkeil commented Apr 4, 2023

The problem is missing environment variables in the ProcessBuilder.

As a test:

fun String.runCommand(workingDir: File): String? {
  try {
    println(">> workingDir: $workingDir")
    val parts = this.split("\\s".toRegex())
    return ProcessBuilder(*parts.toTypedArray())
      .directory(workingDir)
      .redirectOutput(ProcessBuilder.Redirect.PIPE)
      .redirectError(ProcessBuilder.Redirect.PIPE)
      .also { it.environment().putAll(System.getenv()) }
      .start()
      .apply { waitFor(10, TimeUnit.SECONDS) }
      .inputStream.bufferedReader().readText()
  } catch(e: IOException) {
    e.printStackTrace()
    return null
  }
}

println("git status -s".runCommand(rootProject.rootDir))
println(GitCommandRunner.execute(project.projectDir, arrayOf("status", "-s")))

@benkeil benkeil linked a pull request Apr 11, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant