Skip to content

Conversation

@mrjaros
Copy link

@mrjaros mrjaros commented Jul 8, 2014

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"

src/git.erl Outdated
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point

@mrjaros
Copy link
Author

mrjaros commented Jul 9, 2014

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.

@flycodepl
Copy link

-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

git symbolic-ref --short HEAD

see other options: http://stackoverflow.com/a/19585361

@mrjaros
Copy link
Author

mrjaros commented Jul 9, 2014

Good idea to use oksh with strip. I've missed it.

src/git.erl Outdated
Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants