-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #733 from kbase/dev-gradle2_upstream
Add git commit to status() method & build
- Loading branch information
Showing
7 changed files
with
85 additions
and
46 deletions.
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
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,38 @@ | ||
package us.kbase.workspace.gitcommit; | ||
|
||
import java.io.InputStream; | ||
import java.util.Scanner; | ||
|
||
/** The Git commit from which the service was built. Expects a file called "gitcommit" in the same | ||
* directory as the class file which contains the commit hash. | ||
* | ||
* If the file is missing, the Git commit will be replaced with an error message. | ||
* @author [email protected] | ||
* | ||
*/ | ||
public class GitCommit { | ||
|
||
// can't really test this easily since the file must be baked into the jar or war, | ||
// just test manually | ||
|
||
/** The Git commit from which the service was built. */ | ||
public static final String COMMIT; | ||
|
||
private static final String COMMIT_FILE_NAME = "gitcommit"; | ||
|
||
static { | ||
final InputStream is = GitCommit.class.getResourceAsStream(COMMIT_FILE_NAME); | ||
final String commit; | ||
if (is == null) { | ||
commit = "Missing git commit file " + COMMIT_FILE_NAME + | ||
", should be in " + GitCommit.class.getPackage().getName(); | ||
} else { | ||
final Scanner s = new Scanner(is); | ||
s.useDelimiter("\\A"); | ||
commit = s.hasNext() ? s.next() : ""; | ||
s.close(); | ||
} | ||
COMMIT = commit.trim(); | ||
} | ||
|
||
} |
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