forked from toolshed/abra
		
	feat: check and sanitize user-specified tag
This commit is contained in:
		| @ -98,6 +98,13 @@ var recipeReleaseCommand = &cli.Command{ | ||||
| 			logrus.Fatal("Main app's version is empty.") | ||||
| 		} | ||||
|  | ||||
| 		if tagstring != "" { | ||||
| 			_, err := tagcmp.Parse(tagstring) | ||||
| 			if err != nil { | ||||
| 				logrus.Fatal("invalid tag specified") | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		if Commit || (CommitMessage != "") { | ||||
| 			commitRepo, err := git.PlainOpen(directory) | ||||
| 			if err != nil { | ||||
| @ -141,9 +148,21 @@ var recipeReleaseCommand = &cli.Command{ | ||||
|  | ||||
| 		if tagstring != "" { | ||||
| 			if bumpType > 0 { | ||||
| 				logrus.Warn("User specified a version number and --major/--minor/--patch at the same time! Using version number.") | ||||
| 				logrus.Warn("user specified a version number and --major/--minor/--patch at the same time! Using version number.") | ||||
| 			} | ||||
| 			tagstring = fmt.Sprintf("%s+%s", tagstring, mainAppVersion) | ||||
| 			tag, err := tagcmp.Parse(tagstring) | ||||
| 			if err != nil { | ||||
| 				logrus.Fatal(err) | ||||
| 			} | ||||
| 			if tag.MissingMinor { | ||||
| 				tag.Minor = "0" | ||||
| 				tag.MissingMinor = false | ||||
| 			} | ||||
| 			if tag.MissingPatch { | ||||
| 				tag.Patch = "0" | ||||
| 				tag.MissingPatch = false | ||||
| 			} | ||||
| 			tagstring = fmt.Sprintf("%s+%s", tag.String(), mainAppVersion) | ||||
| 			if Dry { | ||||
| 				logrus.Info(fmt.Sprintf("Dry run only. NOT creating tag %s at %s", tagstring, head.Hash())) | ||||
| 				return nil | ||||
| @ -208,15 +227,7 @@ var recipeReleaseCommand = &cli.Command{ | ||||
| 			} | ||||
| 			newTagString = newTag.String() | ||||
| 		} else { | ||||
| 			// calculate the new tag | ||||
| 			var images = make(map[string]tagcmp.Tag) | ||||
| 			for name, version := range imagesTmp { | ||||
| 				t, err := tagcmp.Parse(version) | ||||
| 				if err != nil { | ||||
| 					logrus.Fatal(err) | ||||
| 				} | ||||
| 				images[name] = t | ||||
| 			} | ||||
| 			logrus.Fatal("we don't support auto tag generation yet. Specify a verion or use one of: --major --minor --patch") | ||||
| 		} | ||||
|  | ||||
| 		newTagString = fmt.Sprintf("%s+%s", newTagString, mainAppVersion) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user