-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read version from resource instead of hard-coding it (#220)
* Read version from resource instead of hard-coding it * Moving to stamping to extract the version from tag or default to commit hash * Cleaning up workspace_status.sh
- Loading branch information
1 parent
ebadb18
commit eedaeba
Showing
4 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
package com.bazel_diff.cli | ||
|
||
import picocli.CommandLine.IVersionProvider | ||
import java.io.BufferedReader | ||
import java.io.InputStreamReader | ||
|
||
class VersionProvider : IVersionProvider { | ||
override fun getVersion(): Array<String> { | ||
return arrayOf("7.0.0") | ||
val classLoader = this::class.java.classLoader | ||
val inputStream = classLoader.getResourceAsStream("cli/version") | ||
?: throw IllegalArgumentException("unknown version as version file not found in resources") | ||
|
||
val version = BufferedReader(InputStreamReader(inputStream)).use { it.readText().trim() } | ||
return arrayOf(version) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# Get the current Git tag or default to the commit hash | ||
echo "STABLE_GIT_TAG $(git describe --tags --abbrev=0 2>/dev/null || git rev-parse HEAD)" |