-
Notifications
You must be signed in to change notification settings - Fork 20
Fix git:branch bug when there is more than one branch with equal SHA-ID #7
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
base: master
Are you sure you want to change the base?
Conversation
src/git.erl
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use string:join/2 instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point
use generic string:join instead of specific list_join.
|
hmm, how about just branch(Repo) ->
case status_is_detached(Repo) of
false ->
{ok, B} = sh("git rev-parse --abbrev-ref HEAD", [{cd, Repo}]),
B--"\n";
true ->
detached
end. |
of all branches for current sha.
-spec branch(dir()) -> {'ok', branch()} | 'detached'.
branch(Repo) ->
case status_is_detached(Repo) of
false ->
CurrentBranch = strip(oksh("git symbolic-ref --short HEAD", [{cd, Repo}])),
{ok, CurrentBranch};
true ->
detached
end.And if you don't want to use see other options: http://stackoverflow.com/a/19585361 |
|
Good idea to use oksh with strip. I've missed it. |
src/git.erl
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect. -include_lib automatically finds an application "erlsemver" (even if it located in a folder name with version number) and will find include/semver.hrl from there.
In general -include_lib is preferred over -include.
If you really need to use brute force relative path, use -include.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, my bad, homie. I used this to make c(module) possible, committed and pushed accidentally. Trash it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't trash it on my side. Delete it from PR, so I can merge it :)
This fixes badmatch error when we have more than one branch with equal sha-id. In such case, you tried to match one-element list ([B]) with list of branches (["branchA", "branchB"]). Now we just return list of branches, separated with "; ", ex. "branchA; branchB"