Skip to content

Commit

Permalink
fixed bug that printed "forking" for private repositories even if no …
Browse files Browse the repository at this point in the history
…forking was needed
  • Loading branch information
ipa-tys committed Jun 20, 2012
1 parent bbd7f85 commit 4696bc8
Showing 1 changed file with 12 additions and 28 deletions.
40 changes: 12 additions & 28 deletions githelper
Expand Up @@ -327,41 +327,25 @@ def main():
install_dir = os.path.expanduser(options.install_dir)
if not(os.path.exists( install_dir )):
os.makedirs( install_dir )
print 'Cloning into ' + install_dir

# get list of user repositories
answer = subprocess.Popen('curl -u "' + github_user + ':' + github_pw + '" https://api.github.com/users/' + github_user + '/repos', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
repos = json.loads(answer)
github_user_stacks = []
for rep in repos:
github_user_stacks.append(rep['name'])

# get list of ipa320 repositories
answer = subprocess.Popen('curl -u "' + github_user + ':' + github_pw + '" https://api.github.com/users/ipa320/repos', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
repos = json.loads(answer)
github_ipa_stacks = []
for rep in repos:
github_ipa_stacks.append(rep['name'])
print 'Cloning into ' + install_dir + '\n'
for stack in stacks:
print 'Stack: ' + stack
if os.path.exists( os.path.join(install_dir, stack) ):
print "Already cloned into the specified directory; ignoring. Consider 'githelper pull' to get the latest changes."
elif stack in github_user_stacks:
s = 'git clone git@github.com:' + github_user + '/' + stack + ' ' + os.path.join(install_dir, stack)
answer = subprocess.Popen(s, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if re.search('fatal', answer[1]):
print 'Repository ' + stack + ' could not be cloned. git error message:'
print answer[1] + '\n'
else:
print 'Repository not forked yet. Now forking from ipa320...'
s = 'curl -u "' + github_user + ':' + github_pw + '" -X POST https://api.github.com/repos/ipa320/' + stack + '/forks'
subprocess.Popen(s, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print 'Now cloning...'
s = 'git clone git@github.com:' + github_user + '/' + stack + ' ~/git/care-o-bot/' + stack
s = 'git clone git@github.com:' + github_user + '/' + stack + ' ' + os.path.join(install_dir, stack)
answer = subprocess.Popen(s, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if re.search('fatal', answer[1]):
print 'Repository ' + stack + ' could not be cloned. git error message:'
print answer[1] + '\n'
print 'Repository "' + stack + '" not found in repositories of github user "' + github_user + '".'
print 'Now trying to fork from ipa320...'
s = 'curl -u "' + github_user + ':' + github_pw + '" -X POST https://api.github.com/repos/ipa320/' + stack + '/forks'
subprocess.Popen(s, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
print 'Now trying to clone...'
s = 'git clone git@github.com:' + github_user + '/' + stack + ' ~/git/care-o-bot/' + stack
answer2 = subprocess.Popen(s, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if re.search('fatal', answer2[1]):
print 'Repository ' + stack + ' could not be cloned. git error message:'
print answer2[1] + '\n'
print 'Done.\n'


Expand Down

0 comments on commit 4696bc8

Please sign in to comment.