diff options
| author | Mitchel Humpherys <mitchelh@codeaurora.org> | 2014-03-12 10:48:15 -0700 |
|---|---|---|
| committer | Mitchel Humpherys <mitchelh@codeaurora.org> | 2014-03-12 15:11:27 -0700 |
| commit | eb5acc9ae9148b21afa82b63daec7753b284c03c (patch) | |
| tree | 74c1931b7930a45ae92f0f4791af29778d0d0af6 | |
| parent | 53e902a19b0b80e07ac55966d13c5c84c5b0e8ce (diff) | |
| download | git-repo-eb5acc9ae9148b21afa82b63daec7753b284c03c.tar.gz | |
Don't try to remove .repo if it doesn't exist
Part of the cleanup path for _Init is removing the .repo
directory. However, _Init can fail before creating the .repo directory,
so trying to remove it raises another exception:
fatal: invalid branch name 'refs/changes/53/55053/4'
Traceback (most recent call last):
File "/home/mitchelh/bin/repo", line 775, in <module>
main(sys.argv[1:])
File "/home/mitchelh/bin/repo", line 749, in main
os.rmdir(repodir)
OSError: [Errno 2] No such file or directory: '.repo'
Fix this by only removing .repo if it actually exists.
Change-Id: Ia251d29e9c73e013eb296501d11c36263457e235
| -rwxr-xr-x | repo | 8 |
1 files changed, 2 insertions, 6 deletions
| @@ -114,6 +114,7 @@ import errno | |||
| 114 | import optparse | 114 | import optparse |
| 115 | import os | 115 | import os |
| 116 | import re | 116 | import re |
| 117 | import shutil | ||
| 117 | import stat | 118 | import stat |
| 118 | import subprocess | 119 | import subprocess |
| 119 | import sys | 120 | import sys |
| @@ -741,12 +742,7 @@ def main(orig_args): | |||
| 741 | try: | 742 | try: |
| 742 | _Init(args) | 743 | _Init(args) |
| 743 | except CloneFailure: | 744 | except CloneFailure: |
| 744 | for root, dirs, files in os.walk(repodir, topdown=False): | 745 | shutil.rmtree(repodir, ignore_errors=True) |
| 745 | for name in files: | ||
| 746 | os.remove(os.path.join(root, name)) | ||
| 747 | for name in dirs: | ||
| 748 | os.rmdir(os.path.join(root, name)) | ||
| 749 | os.rmdir(repodir) | ||
| 750 | sys.exit(1) | 746 | sys.exit(1) |
| 751 | repo_main, rel_repo_dir = _FindRepo() | 747 | repo_main, rel_repo_dir = _FindRepo() |
| 752 | else: | 748 | else: |
