Skip to content

Commit

Permalink
Merge pull request #9 from pulumi/fix-dirty-tag
Browse files Browse the repository at this point in the history
Fix dirty tag
  • Loading branch information
jaxxstorm committed May 26, 2020
2 parents d14cbec + 6892987 commit 635efdf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,7 @@ fabric.properties

# Goreleaser
dist/

# IDE
.code
.idea
13 changes: 10 additions & 3 deletions pkg/gitversion/gitversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,15 @@ func GetLanguageVersions(workingDirPath string, commitish plumbing.Revision) (*L
}
}

// Detect if the git worktree is dirty, and add `.dirty` to the version if it is
// Detect if the git worktree is dirty, and add `dirty` to the version if it is
if versionComponents.Dirty {
preVersion = fmt.Sprintf("%s.dirty", preVersion)
pythonPreVersion = fmt.Sprintf("%s+dirty", pythonPreVersion)
if versionComponents.IsExact {
preVersion = fmt.Sprintf("%s+dirty", preVersion)
pythonPreVersion = fmt.Sprintf("%s+dirty", pythonPreVersion)
} else {
preVersion = fmt.Sprintf("%s.dirty", preVersion)
pythonPreVersion = fmt.Sprintf("%s+dirty", pythonPreVersion)
}
}

// a base version with the pre release info
Expand All @@ -95,6 +100,7 @@ type versionComponents struct {
Dirty bool
ShortHash string
Timestamp time.Time
IsExact bool
}

// versionAtCommitForRepo determines the version components on which the language-specific variants
Expand Down Expand Up @@ -148,6 +154,7 @@ func versionAtCommitForRepo(workingDirPath string, commitish plumbing.Revision)
Dirty: isDirty,
ShortHash: revision.String()[:8],
Timestamp: commit.Committer.When,
IsExact: isExact,
}, nil
}

Expand Down

0 comments on commit 635efdf

Please sign in to comment.