-
Notifications
You must be signed in to change notification settings - Fork 22
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
update release.py #6
Conversation
scripts/release.py
Outdated
if current_tag[0] != 'v': | ||
raise Exception("The tag name should start with v") | ||
|
||
if not re.match("^v[0-9][.][0-9]", current_tag): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The major number can have multiple digits. So the regexp should ^v[0-9]+[.][0-9]
scripts/release.py
Outdated
|
||
if not re.match("^v[0-9][.][0-9]", current_tag): | ||
raise Exception("Error: tag name does not follow expected pattern.") | ||
|
||
major_version = int(current_tag[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works with single-digit number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To address this, in you first get the index of the .
.
Then get the major version by slicing the string from the second character until the .
character.
For the minor version, just the characters after .
.
scripts/release.py
Outdated
@@ -46,7 +47,7 @@ def main(): | |||
jar = build_binary() | |||
|
|||
# release | |||
release_command = ['hub', 'release', 'create', '-a', jar, '-m', title, tag_name] | |||
release_command = ['hub', 'release', 'create', '-o', '-a', jar, '-m', title, tag_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For scripts, it is better to use long flags than short flags.
Short flags are useful for interactive shells, while long flags are helpful for documentation purpose.
@@ -46,7 +47,7 @@ def main(): | |||
jar = build_binary() | |||
|
|||
# release | |||
release_command = ['hub', 'release', 'create', '-a', jar, '-m', title, tag_name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be improved with f-string.
scripts/release.py
Outdated
|
||
if not re.match("^v[0-9][.][0-9]", current_tag): | ||
raise Exception("Error: tag name does not follow expected pattern.") | ||
|
||
major_version = int(current_tag[1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To address this, in you first get the index of the .
.
Then get the major version by slicing the string from the second character until the .
character.
For the minor version, just the characters after .
.
Imported 're' lib to detect validity of tag names.