Make SystemExit errors less redundant in output; verify clean git status on master.

This commit is contained in:
Nathan Wilcox 2017-05-19 13:05:55 -07:00
parent 3250b3d34e
commit b9b7f25fb9
1 changed files with 16 additions and 1 deletions

View File

@ -25,7 +25,7 @@ def main(args=sys.argv[1:]):
main_logged(opts.RELEASE_VERSION, opts.RELEASE_PREV)
except SystemExit as e:
logging.error(str(e))
raise
raise SystemExit(1)
except:
logging.error(traceback.format_exc())
raise
@ -34,6 +34,7 @@ def main(args=sys.argv[1:]):
# Top-level flow:
def main_logged(release, releaseprev):
verify_releaseprev_tag(releaseprev)
verify_git_clean_master()
raise NotImplementedError(main_logged)
@ -74,6 +75,20 @@ def verify_releaseprev_tag(releaseprev):
)
def verify_git_clean_master():
junk = sh_out('git', 'status', '--porcelain')
if junk.strip():
raise SystemExit('There are uncommitted changes:\n' + junk)
branch = sh_out('git', 'rev-parse', '--abbrev-ref', 'HEAD').strip()
if branch != 'master':
raise SystemExit(
"Expected branch 'master', found branch {!r}".format(
branch,
),
)
# Helper code:
def chdir_to_repo():
dn = os.path.dirname