-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report the git commit hash in groupversion_info_gen.go (#150)
This will help us trace a generated package back to the code that produced it. The git commit hash (and whether the tree is dirty) is fed into the build from the Makefile.
- Loading branch information
1 parent
bd2bad2
commit db0082d
Showing
5 changed files
with
74 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
*/ | ||
|
||
package astmodel | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestPackageGroupVersion_IncludesGeneratorVersion(t *testing.T) { | ||
g := NewGomegaWithT(t) | ||
|
||
pkg := NewPackageDefinition("longest-johns", "santiana", "latest-version") | ||
|
||
destDir, err := ioutil.TempDir("", "package_definition_test") | ||
g.Expect(err).To(BeNil()) | ||
defer os.RemoveAll(destDir) | ||
|
||
fileCount, err := pkg.EmitDefinitions(destDir) | ||
g.Expect(err).To(BeNil()) | ||
g.Expect(fileCount).To(Equal(0)) | ||
|
||
gvFile := filepath.Join(destDir, "groupversion_info_gen.go") | ||
data, err := ioutil.ReadFile(gvFile) | ||
g.Expect(err).To(BeNil()) | ||
g.Expect(string(data)).To(ContainSubstring("// Generator version: latest-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
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,24 @@ | ||
/* | ||
* Copyright (c) Microsoft Corporation. | ||
* Licensed under the MIT license. | ||
*/ | ||
|
||
package codegen | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
var ( | ||
// GitCommit and GitTreeState are populated by the Makefile. | ||
GitCommit string | ||
GitTreeState string | ||
) | ||
|
||
func combinedVersion() string { | ||
result := GitCommit | ||
if GitTreeState != "clean" { | ||
result += fmt.Sprintf(" (tree is %s)", GitTreeState) | ||
} | ||
return result | ||
} |