Skip to content

Commit e0b2c79

Browse files
committed
fix commit injection
1 parent 7bb7a1f commit e0b2c79

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,22 @@ func pathResolver(cwd string, path string) (string, error) {
6565
return path, nil
6666
}
6767

68+
func getCommit() string {
69+
if commit == "" {
70+
return "HEAD"
71+
}
72+
73+
if len(commit) > 7 {
74+
return commit[:7]
75+
}
76+
77+
return commit
78+
}
79+
6880
func main() {
6981
app := &cli.App{
7082
Name: "flint",
71-
Version: fmt.Sprintf("%s (%s), built at %s", version, commit[:8], date),
83+
Version: fmt.Sprintf("%s (%s), built at %s", version, getCommit(), date),
7284
Usage: "extensible frontmatter linter",
7385
Flags: []cli.Flag{
7486
&cli.PathFlag{

0 commit comments

Comments
 (0)