I’m writing a semi-automated deploy script that allows users to tag the repository at deploy time. Right now it simply prompts for input and attempts to use whatever value is entered as the tag name:
current_tag = local("git describe --abbrev=0", capture=True)
new_tag = prompt("New version (currently %s)?" % current_tag)
local("git tag -a '%s'" % new_tag)
What kind of checking and validation should I perform between the prompt and the git tag -a?
Presumably, if the script is meant to deploy software, you trust your users, and what are you trying to do is just to prevent invalid chars or wrong syntax to break the script right?
If that is the case I would simply check that the command executes correctly by looking at its exit status. It’s sort of EAFP (“It’s easier to ask for forgiveness than it is to get permission”) approach that should automatically accomodate for future possible variations of git’s syntax.