rossabaker / abolish-ice-graphiti

Script to make your GitHub contribution graph read "abolish ice"
Creative Commons Zero v1.0 Universal
16 stars 6 forks source link

get current branch name #7

Closed wolfwood closed 4 years ago

wolfwood commented 4 years ago

currently paint.sh assumes a branch name of master. if that is not the current branch name, script fails with a somewhat confusing message about an invalid refspec.

this patch #WorksForMe

BenBE commented 4 years ago

Still fails if the remote origin is not pushable; as it is in my case.

Maybe better use:

# Get remote name
a="$(git rev-parse --abbrev-ref HEAD@{u} || echo origin/"$(git rev-parse --abbrev-ref HEAD)")"
remote="${a%%/*}"
remote="${remote:-origin}"
branch="${a#*/}"
branch="${branch:-master}"
git push "$remote" HEAD:"$branch"

Untested, but should do. Using something similar in https://github.com/benbe/git-prompt

wolfwood commented 4 years ago

looks like git branch --show-current is sufficient for the branch (though this may be recent syntax?), maybe git remote show is sufficient for the origin?

rossabaker commented 4 years ago

Worked for me.