mirror of
				https://github.com/Dev-Wiki/git-repo.git
				synced 2025-11-04 01:54:12 +08:00 
			
		
		
		
	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
			
			
This commit is contained in:
		
							
								
								
									
										8
									
								
								repo
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								repo
									
									
									
									
									
								
							@@ -114,6 +114,7 @@ import errno
 | 
			
		||||
import optparse
 | 
			
		||||
import os
 | 
			
		||||
import re
 | 
			
		||||
import shutil
 | 
			
		||||
import stat
 | 
			
		||||
import subprocess
 | 
			
		||||
import sys
 | 
			
		||||
@@ -741,12 +742,7 @@ def main(orig_args):
 | 
			
		||||
      try:
 | 
			
		||||
        _Init(args)
 | 
			
		||||
      except CloneFailure:
 | 
			
		||||
        for root, dirs, files in os.walk(repodir, topdown=False):
 | 
			
		||||
          for name in files:
 | 
			
		||||
            os.remove(os.path.join(root, name))
 | 
			
		||||
          for name in dirs:
 | 
			
		||||
            os.rmdir(os.path.join(root, name))
 | 
			
		||||
        os.rmdir(repodir)
 | 
			
		||||
        shutil.rmtree(repodir, ignore_errors=True)
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
      repo_main, rel_repo_dir = _FindRepo()
 | 
			
		||||
    else:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user