mirror of
https://github.com/fiatjaf/nak.git
synced 2025-12-22 22:48:50 +00:00
git: fix --tags
This commit is contained in:
55
git.go
55
git.go
@@ -532,34 +532,37 @@ aside from those, there is also:
|
|||||||
log("- setting HEAD to branch %s\n", color.CyanString(remoteBranch))
|
log("- setting HEAD to branch %s\n", color.CyanString(remoteBranch))
|
||||||
}
|
}
|
||||||
|
|
||||||
// add all refs/tags
|
if c.Bool("tags") {
|
||||||
output, err := exec.Command("git", "show-ref", "--tags").Output()
|
// add all refs/tags
|
||||||
if err != nil {
|
output, err := exec.Command("git", "show-ref", "--tags").Output()
|
||||||
return fmt.Errorf("failed to get local tags: %s", err)
|
if err != nil && err.Error() != "exit status 1" {
|
||||||
} else {
|
// exit status 1 is returned when there are no tags, which should be ok for us
|
||||||
lines := strings.Split(strings.TrimSpace(string(output)), "\n")
|
return fmt.Errorf("failed to get local tags: %s", err)
|
||||||
for _, line := range lines {
|
} else {
|
||||||
line = strings.TrimSpace(line)
|
lines := strings.Split(strings.TrimSpace(string(output)), "\n")
|
||||||
if line == "" {
|
for _, line := range lines {
|
||||||
continue
|
line = strings.TrimSpace(line)
|
||||||
}
|
if line == "" {
|
||||||
parts := strings.Fields(line)
|
continue
|
||||||
if len(parts) != 2 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
commitHash := parts[0]
|
|
||||||
ref := parts[1]
|
|
||||||
|
|
||||||
tagName := strings.TrimPrefix(ref, "refs/tags/")
|
|
||||||
|
|
||||||
if !c.Bool("force") {
|
|
||||||
// if --force is not passed then we can't overwrite tags
|
|
||||||
if existingHash, exists := state.Tags[tagName]; exists && existingHash != commitHash {
|
|
||||||
return fmt.Errorf("tag %s that is already published pointing to %s, call with --force to overwrite", tagName, existingHash)
|
|
||||||
}
|
}
|
||||||
|
parts := strings.Fields(line)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
commitHash := parts[0]
|
||||||
|
ref := parts[1]
|
||||||
|
|
||||||
|
tagName := strings.TrimPrefix(ref, "refs/tags/")
|
||||||
|
|
||||||
|
if !c.Bool("force") {
|
||||||
|
// if --force is not passed then we can't overwrite tags
|
||||||
|
if existingHash, exists := state.Tags[tagName]; exists && existingHash != commitHash {
|
||||||
|
return fmt.Errorf("tag %s that is already published pointing to %s, call with --force to overwrite", tagName, existingHash)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
state.Tags[tagName] = commitHash
|
||||||
|
log("- setting tag %s to commit %s\n", color.CyanString(tagName), color.CyanString(commitHash))
|
||||||
}
|
}
|
||||||
state.Tags[tagName] = commitHash
|
|
||||||
log("- setting tag %s to commit %s\n", color.CyanString(tagName), color.CyanString(commitHash))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user