forked from toolshed/abra
refactor: improved version choice flow
This commit is contained in:
@ -99,6 +99,14 @@ keys configured on your account.
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if tagString == "" {
|
||||
var err error
|
||||
tagString, err = getLabelVersion(recipe)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
if len(tags) > 0 {
|
||||
logrus.Warnf("previous git tags detected, assuming this is a new semver release")
|
||||
if err := createReleaseFromPreviousTag(tagString, mainAppVersion, recipe, tags); err != nil {
|
||||
@ -107,32 +115,8 @@ keys configured on your account.
|
||||
} else {
|
||||
logrus.Warnf("no tag specified and no previous tag available for %s, assuming this is the initial release", recipe.Name)
|
||||
|
||||
initTag, err := recipePkg.GetVersionLabelLocal(recipe)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if initTag == "" {
|
||||
logrus.Fatalf("unable to read version for %s from synced label. Did you try running \"abra recipe sync %s\" already?", recipe.Name, recipe.Name)
|
||||
}
|
||||
|
||||
logrus.Warnf("discovered %s as currently synced recipe label", initTag)
|
||||
|
||||
prompt := &survey.Confirm{
|
||||
Message: fmt.Sprintf("use %s as the initial release?", initTag),
|
||||
}
|
||||
|
||||
var response bool
|
||||
if err := survey.AskOne(prompt, &response); err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
if !response {
|
||||
logrus.Fatalf("please fix your synced label for %s and re-run this command", recipe.Name)
|
||||
}
|
||||
|
||||
if err := createReleaseFromTag(recipe, initTag, mainAppVersion); err != nil {
|
||||
if cleanUpErr := cleanUpTag(initTag, recipe.Name); err != nil {
|
||||
if err := createReleaseFromTag(recipe, tagString, mainAppVersion); err != nil {
|
||||
if cleanUpErr := cleanUpTag(tagString, recipe.Name); err != nil {
|
||||
logrus.Fatal(cleanUpErr)
|
||||
}
|
||||
logrus.Fatal(err)
|
||||
@ -417,10 +401,39 @@ func cleanUpTag(tag, recipeName string) error {
|
||||
}
|
||||
|
||||
if err := repo.DeleteTag(tag); err != nil {
|
||||
return err
|
||||
if !strings.Contains(err.Error(), "not found") {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
logrus.Debugf("removed freshly created tag %s", tag)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getLabelVersion(recipe recipe.Recipe) (string, error) {
|
||||
initTag, err := recipePkg.GetVersionLabelLocal(recipe)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if initTag == "" {
|
||||
logrus.Fatalf("unable to read version for %s from synced label. Did you try running \"abra recipe sync %s\" already?", recipe.Name, recipe.Name)
|
||||
}
|
||||
|
||||
logrus.Warnf("discovered %s as currently synced recipe label", initTag)
|
||||
|
||||
if !internal.NoInput {
|
||||
var response bool
|
||||
prompt := &survey.Confirm{Message: fmt.Sprintf("use %s as the new version?", initTag)}
|
||||
if err := survey.AskOne(prompt, &response); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if !response {
|
||||
return "", fmt.Errorf("please fix your synced label for %s and re-run this command", recipe.Name)
|
||||
}
|
||||
}
|
||||
|
||||
return initTag, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user