@@ -21,31 +21,46 @@ import (
2121
2222func init () {
2323 initParserVersion ()
24+ initParserGitCommit ()
2425}
2526
26- var gParserVersion = "uninitialized"
27+ const uninitialized = "uninitialized"
28+
29+ var (
30+ gParserVersion = uninitialized
31+ gParserGitCommit = uninitialized
32+ )
2733
2834// initParserVersion initializes the gParserVersion variable for use by all parsers.
2935func initParserVersion () string {
3036 release := etl .Version
3137 if release != "noversion" {
3238 gParserVersion = "https://github.com/m-lab/etl/tree/" + release
3339 } else {
34- hash := etl .GitCommit
35- if hash != "nocommit" && len (hash ) >= 8 {
36- gParserVersion = "https://github.com/m-lab/etl/tree/" + hash [0 :8 ]
37- } else {
38- gParserVersion = "local development"
39- }
40+ gParserVersion = "local development"
4041 }
4142 return gParserVersion
4243}
4344
45+ // initParserGitCommit initializes the gParserGitCommit variable for use by all parsers.
46+ func initParserGitCommit () string {
47+ hash := etl .GitCommit
48+ if hash != "nocommit" {
49+ gParserGitCommit = hash
50+ }
51+ return gParserGitCommit
52+ }
53+
4454// Version returns the parser version used by parsers to annotate data rows.
4555func Version () string {
4656 return gParserVersion
4757}
4858
59+ // GitCommit returns the git commit hash of the build.
60+ func GitCommit () string {
61+ return gParserGitCommit
62+ }
63+
4964// NewSinkParser creates an appropriate parser for a given data type.
5065// Eventually all datatypes will use this instead of NewParser.
5166func NewSinkParser (dt etl.DataType , sink row.Sink , table string , ann api.Annotator ) etl.Parser {
0 commit comments