Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(internal/carver): don't tag commits #4518

Merged
merged 3 commits into from Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/carver/cmd/_tidyhack_tmpl.txt
Expand Up @@ -19,4 +19,4 @@
package {{.Package}}

// Necessary for safely adding multi-module repo. See: https://github.com/golang/go/wiki/Modules#is-it-possible-to-add-a-module-to-a-multi-module-repository
import _ "{{.RootMod}}"
import _ "{{.RootMod}}"
26 changes: 8 additions & 18 deletions internal/carver/cmd/main.go
Expand Up @@ -94,7 +94,6 @@ func main() {
flag.Usage()
os.Exit(1)
}
log.Println("Successfully carved out module. Changes are ready to be pushed.")
}

func (c *carver) Run() error {
Expand Down Expand Up @@ -304,6 +303,7 @@ func (c *carver) CreateGitTags(rootMod *modInfo) error {
return err
}
childPrefix := strings.TrimPrefix(strings.TrimPrefix(c.childModPath, rootMod.filePath), "/")
childModTag := fmt.Sprintf("%s/%s", childPrefix, c.childTagVersion)
log.Println("Commiting changes")
if !c.dryRun {
cmd := exec.Command("git", "add", "-A")
Expand All @@ -312,28 +312,18 @@ func (c *carver) CreateGitTags(rootMod *modInfo) error {
return fmt.Errorf("unable to add changes: %s", b)
}
cmd = exec.Command("git", "commit", "-m",
fmt.Sprintf("chore(%s): carve out sub-module", childPrefix))
fmt.Sprintf("chore(%s): carve out sub-module\n\nThis commit will be tagged %s and %s.", childPrefix, futureTag, childModTag))
cmd.Dir = c.parentModPath
if b, err := cmd.Output(); err != nil {
return fmt.Errorf("unable to commit changes: %s", b)
}
}
log.Printf("Tagging Root module: %s", futureTag)
if !c.dryRun {
cmd := exec.Command("git", "tag", futureTag)
cmd.Dir = c.parentModPath
if b, err := cmd.Output(); err != nil {
return fmt.Errorf("unable to tag root module: %s", b)
}
}
log.Printf("Tagging Child module: %s/%s", childPrefix, c.childTagVersion)
if !c.dryRun {
cmd := exec.Command("git", "tag", fmt.Sprintf("%s/%s", childPrefix, c.childTagVersion))
cmd.Dir = c.parentModPath
if b, err := cmd.Output(); err != nil {
return fmt.Errorf("unable to tag child module: %s", b)
}
}
log.Println("Successfully carved out module. Please run the following commands after your change is merged:")
fmt.Fprintf(os.Stdout, "git tag -a %s <COMMIT-SHA>\n", futureTag)
fmt.Fprintf(os.Stdout, "git tag -a %s <COMMIT-SHA>\n", childModTag)
fmt.Fprintf(os.Stdout, "git push origin ref/tags/%s\n", futureTag)
fmt.Fprintf(os.Stdout, "git push origin ref/tags/%s\n", childModTag)

return nil
}

Expand Down