Comments (9)
There is some support, https://metacpan.org/pod/Git::Raw::Repository#revparse(-$spec-)
from p5-git-raw.
Use discover
instead of open
.
from p5-git-raw.
Check out the Git::Raw::Branch
documentation. It has lookup
, upstream_name
and maybe remote_name
which I think would be of use here.
Also, $repo->head
should give you a Git::Raw::Reference
for HEAD
, which has name
etc.
from p5-git-raw.
Have a look at t/25-revparse.t
for usage examples.
from p5-git-raw.
I see, I was looking for in particular for these two:
rev-parse --abbrev-ref HEAD
rev-parse --show-toplevel
from p5-git-raw.
libgit2 and Git::Raw provide building blocks to implement these yourself.
rev-parse --show-toplevel
I think is as simple as calling $repo->workdir
.
rev-parse --abbrev-ref HEAD
I think could be implemented by calling Git::Raw::Commit->lookup ($repo, $id)
where you chop off characters until you get an error? Would expect it to be a Git::Raw::Error->EAMBIGUOUS
from p5-git-raw.
The first one doesn't work when you aren't in the top of your working dir:
$ cat t/foo.pl
#!/usr/bin/perl
use warnings;
use strict;
use Git::Raw::Repository;
use Cwd qw(cwd);
my $repo = Git::Raw::Repository->open(cwd());
print $repo->workdir, $/;
14:10 pts/3 0 wesleys@neptune:/home/wesleys/code/git-repo
$ perl t/foo.pl
/home/wesleys/code/git-repo/
14:10 pts/3 0 wesleys@neptune:/home/wesleys/code/git-repo
$ cd t
14:10 pts/3 0 wesleys@neptune:/home/wesleys/code/git-repo/t
$ perl foo.pl
could not find repository from '/home/wesleys/code/git-repo/t' at foo.pl line 814:11 pts/3 2 wesleys@neptune:/home/wesleys/code/git-repo/t
$
from p5-git-raw.
That works! Thanks.
The latter command spits out the branch you are in, and I also want something that returns the tracking branch which I do with git rev-parse --abbrev-ref @{u}
from p5-git-raw.
Will do!
from p5-git-raw.
Related Issues (20)
- Add support for commit trailers HOT 4
- -m32 option makes build fail on most 32 bit arches HOT 4
- please make convenience copy of libgit2 et all identifyable HOT 2
- ppport.h:4594: warning: "WIDEST_UTYPE" redefined HOT 1
- Getting a [-Wstringop-truncation] warning in Walker.xs
- Error during dzil test
- Provide Makefile.PL / cpanfile in git repo HOT 3
- API of Config->set, get to replace str, int, bool HOT 7
- Request: support enumeration and traversal of submodules HOT 6
- Refspec issue with patterns, HOT 4
- libssh2 deprecated in Redhat 7 HOT 2
- Git::Raw::Graph()->is_descendant_of doesn't propagate error codes HOT 1
- Unable to install Git::Raw on AIX 7.2 HOT 1
- Test failure with libgit2-dev 1.3.0 HOT 9
- There are various CVEs for embedded libraries HOT 5
- main vs master HOT 1
- SIGSEGV in test suite
- amending a commit
- does not compile on windows with latest strawberry perl HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p5-git-raw.