refactor: less quotes, spacing for style

This commit is contained in:
decentral1se 2021-12-21 02:04:56 +01:00
parent f75284364d
commit 0dc4b2beef
Signed by: decentral1se
GPG Key ID: 03789458B3D0C410
1 changed files with 15 additions and 2 deletions

View File

@ -81,7 +81,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
} }
if mainAppVersion == "" { if mainAppVersion == "" {
logrus.Fatalf("main 'app' service version for %s is empty?", recipe.Name) logrus.Fatalf("main app service version for %s is empty?", recipe.Name)
} }
if tagString != "" { if tagString != "" {
@ -116,6 +116,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
Message: "tag message", Message: "tag message",
Default: fmt.Sprintf("chore: publish new %s version", internal.GetBumpType()), Default: fmt.Sprintf("chore: publish new %s version", internal.GetBumpType()),
} }
if err := survey.AskOne(prompt, &internal.TagMessage); err != nil { if err := survey.AskOne(prompt, &internal.TagMessage); err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
@ -128,6 +129,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
prompt := &survey.Confirm{ prompt := &survey.Confirm{
Message: "git commit changes also?", Message: "git commit changes also?",
} }
if err := survey.AskOne(prompt, &internal.Commit); err != nil { if err := survey.AskOne(prompt, &internal.Commit); err != nil {
return err return err
} }
@ -137,6 +139,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
prompt := &survey.Confirm{ prompt := &survey.Confirm{
Message: "git push changes also?", Message: "git push changes also?",
} }
if err := survey.AskOne(prompt, &internal.Push); err != nil { if err := survey.AskOne(prompt, &internal.Push); err != nil {
return err return err
} }
@ -160,13 +163,13 @@ You may invoke this command in "wizard" mode and be prompted for input:
if err := gitPkg.Commit("compose.**yml", internal.CommitMessage, internal.Dry, false); err != nil { if err := gitPkg.Commit("compose.**yml", internal.CommitMessage, internal.Dry, false); err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
} }
repo, err := git.PlainOpen(directory) repo, err := git.PlainOpen(directory)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
head, err := repo.Head() head, err := repo.Head()
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
@ -177,14 +180,17 @@ You may invoke this command in "wizard" mode and be prompted for input:
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
if tag.MissingMinor { if tag.MissingMinor {
tag.Minor = "0" tag.Minor = "0"
tag.MissingMinor = false tag.MissingMinor = false
} }
if tag.MissingPatch { if tag.MissingPatch {
tag.Patch = "0" tag.Patch = "0"
tag.MissingPatch = false tag.MissingPatch = false
} }
tagString = fmt.Sprintf("%s+%s", tag.String(), mainAppVersion) tagString = fmt.Sprintf("%s+%s", tag.String(), mainAppVersion)
if internal.Dry { if internal.Dry {
hash := abraFormatter.SmallSHA(head.Hash().String()) hash := abraFormatter.SmallSHA(head.Hash().String())
@ -213,20 +219,24 @@ You may invoke this command in "wizard" mode and be prompted for input:
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
if err := iter.ForEach(func(ref *plumbing.Reference) error { if err := iter.ForEach(func(ref *plumbing.Reference) error {
obj, err := repo.TagObject(ref.Hash()) obj, err := repo.TagObject(ref.Hash())
if err != nil { if err != nil {
return err return err
} }
tagcmpTag, err := tagcmp.Parse(obj.Name) tagcmpTag, err := tagcmp.Parse(obj.Name)
if err != nil { if err != nil {
return err return err
} }
if (lastGitTag == tagcmp.Tag{}) { if (lastGitTag == tagcmp.Tag{}) {
lastGitTag = tagcmpTag lastGitTag = tagcmpTag
} else if tagcmpTag.IsGreaterThan(lastGitTag) { } else if tagcmpTag.IsGreaterThan(lastGitTag) {
lastGitTag = tagcmpTag lastGitTag = tagcmpTag
} }
return nil return nil
}); err != nil { }); err != nil {
logrus.Fatal(err) logrus.Fatal(err)
@ -240,12 +250,14 @@ You may invoke this command in "wizard" mode and be prompted for input:
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
newTag.Patch = strconv.Itoa(now + 1) newTag.Patch = strconv.Itoa(now + 1)
} else if internal.Minor { } else if internal.Minor {
now, err := strconv.Atoi(newTag.Minor) now, err := strconv.Atoi(newTag.Minor)
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
newTag.Patch = "0" newTag.Patch = "0"
newTag.Minor = strconv.Itoa(now + 1) newTag.Minor = strconv.Itoa(now + 1)
} else if internal.Major { } else if internal.Major {
@ -253,6 +265,7 @@ You may invoke this command in "wizard" mode and be prompted for input:
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
newTag.Patch = "0" newTag.Patch = "0"
newTag.Minor = "0" newTag.Minor = "0"
newTag.Major = strconv.Itoa(now + 1) newTag.Major = strconv.Itoa(now + 1)