Fix no_git_dir UnboundLocalError in except block
In Python 3, exception blocks clean their variables up, and we get a UnbloundLocalError when we try to reference the target outside of the except block. To pass the exception out we set a variable from the target. Also pull --license above raising the error, as it should work outside a git repo too. https://www.python.org/dev/peps/pep-3110/#semantic-changes Change-Id: I298ac3648068cd07c4cf232e32ab3daaaf8e549d
This commit is contained in:
parent
aaa416e697
commit
58a23a938a
@ -1418,8 +1418,8 @@ def _main():
|
||||
yes=False)
|
||||
try:
|
||||
(top_dir, git_dir) = git_directories()
|
||||
except GitDirectoriesException as no_git_dir:
|
||||
pass
|
||||
except GitDirectoriesException as _no_git_dir:
|
||||
no_git_dir = _no_git_dir
|
||||
else:
|
||||
no_git_dir = False
|
||||
config = Config(os.path.join(top_dir, ".gitreview"))
|
||||
@ -1428,13 +1428,14 @@ def _main():
|
||||
remote=None,
|
||||
usepushurl=convert_bool(config['usepushurl']))
|
||||
options = parser.parse_args()
|
||||
if no_git_dir:
|
||||
raise no_git_dir
|
||||
|
||||
if options.license:
|
||||
print(COPYRIGHT)
|
||||
sys.exit(0)
|
||||
|
||||
if no_git_dir:
|
||||
raise no_git_dir
|
||||
|
||||
if options.branch is None:
|
||||
branch = config['branch']
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user