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

Determine current branch in rugged. #314

Closed
rhodee opened this issue Feb 16, 2014 · 2 comments
Closed

Determine current branch in rugged. #314

rhodee opened this issue Feb 16, 2014 · 2 comments

Comments

@rhodee
Copy link

rhodee commented Feb 16, 2014

What is the rugged equivalent to listing the current branch (e.g. git rev-parse --abbrev-ref -q HEAD)?

I tried this implementation and it returns a short name repo.head.name.split('/')[-1]. But not sure it is the desired way to do this.

@arthurschreiber
Copy link
Member

A better way would be:

repo.head.name.sub(/^refs\/heads\//, '')

Your version won't work correctly when the ref name has a / in it.

@rhodee
Copy link
Author

rhodee commented Feb 17, 2014

@arthurschreiber thank you for the work on rugged and the proper regex.

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

No branches or pull requests

2 participants