From bd407b64f619dad0f295fcd1e0ed51bf50510465 Mon Sep 17 00:00:00 2001 From: Andrew Griffiths Date: Mon, 23 Jan 2017 12:14:31 +0000 Subject: [PATCH] Cleaner git-fork code for github API call --- bin/git-fork | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/git-fork b/bin/git-fork index 4f8a4ebc1..01c913799 100755 --- a/bin/git-fork +++ b/bin/git-fork @@ -31,9 +31,12 @@ fi [ -z "$project" -o -z "$owner" ] && abort "github repo needs to be specified as an argument" # create fork -curl_args="-qs -X POST -u $user" -curl_url="https://api.github.com/repos/$owner/$project/forks" -RES=$(curl -H "X-GitHub-OTP: $MFA_CODE" $curl_args "$curl_url") +curl -qs \ + -X POST \ + -u "$user" \ + -H "X-GitHub-OTP: $MFA_CODE" \ + "https://api.github.com/repos/$owner/$project/forks" + [ $? = 0 ] || abort "fork failed" # Check if user has ssh configured with GitHub @@ -45,13 +48,13 @@ fi if [ "$origin" = true ]; then git remote rename origin upstream - git remote add origin "$remote_prefix$user/${project}.git" + git remote add origin "${remote_prefix}${user}/${project}.git" git fetch origin else # clone forked repo into current dir - git clone "$remote_prefix$user/${project}.git" "$project" + git clone "${remote_prefix}${user}/${project}.git" "$project" # add reference to origin fork so can merge in upstream changes cd "$project" - git remote add upstream "$remote_prefix$owner/${project}.git" + git remote add upstream "${remote_prefix}${owner}/${project}.git" git fetch upstream fi