Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ticket 137 - Bugfix (wrong email address uploaded) #10

Merged
merged 1 commit into from Jun 21, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions githelper
Expand Up @@ -206,20 +206,20 @@ def main():
print 'Login on github successful.\n'

# fetch email from github:
ans = subprocess.Popen('curl https://api.github.com/users/ipa-tys', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].strip()
ans = subprocess.Popen('curl https://api.github.com/users/' + github_user, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].strip()
userdata = json.loads(ans)
if "email" not in userdata or len(userdata['email'])==0:
user_email = subprocess.Popen('git config --global user.email', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0].strip()
if len(user_email) > 0:
print "No email address found on github. Uploading email address found in .gitconfig: " + user_email
os.system('git config --global github.email "' + user_email + '"')
os.system('curl -s -u ipa-tys:anne2606 -i -X PATCH -d \'{"email":"' + user_email + '"}\' https://api.github.com/user > /dev/null')
os.system('curl -s -u "' + github_user + ':' + github_pw + '" -i -X PATCH -d \'{"email":"' + user_email + '"}\' https://api.github.com/user > /dev/null')
else:
print "No email address found on github and in .gitconfig."
user_email = raw_input("Please enter your email address: ")
os.system('git config --global user.email "' + user_email + '"')
os.system('git config --global github.email "' + user_email + '"')
os.system('curl -s -u ipa-tys:anne2606 -i -X PATCH -d \'{"email":"' + user_email + '"}\' https://api.github.com/user > /dev/null')
os.system('curl -s -u "' + github_user + ':' + github_pw + '" -i -X PATCH -d \'{"email":"' + user_email + '"}\' https://api.github.com/user > /dev/null')
else:
print "Adding email address found on github to .gitconfig: " + userdata['email']
os.system('git config --global user.email "' + userdata['email'] + '"')
Expand All @@ -239,7 +239,7 @@ def main():
f = open(os.path.expanduser('~/.ssh/id_rsa.pub'), 'r')
rsaKey = f.read().strip()
f.close()
tt = 'curl -i -H "Accept: application/json" -H "Content-Type: application/json" --user ' + github_user + ':' + github_pw + ' -X POST -d \'{"title":"' + rsaTitle + '","key":"' + rsaKey + '"}\' https://api.github.com/user/keys'
tt = 'curl -i -H "Accept: application/json" -H "Content-Type: application/json" -u "' + github_user + ':' + github_pw + '" -X POST -d \'{"title":"' + rsaTitle + '","key":"' + rsaKey + '"}\' https://api.github.com/user/keys'
output = subprocess.Popen(tt, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0]
if re.search('key is already in use', output):
print 'Key is already uploaded to github; done.'
Expand Down