02 Nov 2021 01:32:35 UTC
- Distribution: Git-Helpers
- Module version: 1.000001
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (425 / 2 / 2)
- KwaliteeBus factor: 1
- 96.43% Coverage
- License: perl_5
- Perl: v5.12.0
- Activity24 month
- Download (27.93KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version++ed by:OALDERS Olaf Alders 🐫
- COPYRIGHT AND LICENSE
Git::Helpers - Shortcuts for common Git commands
use Git::Helpers qw( checkout_root current_branch_name https_remote_url is_inside_work_tree remote_url ); my $dir = '/path/to/folder/in/git/checkout'; my $root = checkout_root($dir); my $current_branch = current_branch_name(); my $https_remote_url = https_remote_url(); my $inside_work_tree = is_inside_work_tree(); my $remote_url = remote_url('upstream');
Gives you the root level of the git checkout which you are currently in. Optionally accepts a directory parameter. If you provide the directory parameter,
chdirto this directory and find the top level of the repository.
This method will throw an exception if it cannot find a git repository at the directory provided.
Returns the name of the current branch.
This is a browser-friendly URL for the remote, fixed up in such a way that GitHub (hopefully) doesn't need to redirect your URL.
Turns email@example.com:oalders/git-helpers.git into https://github.com/oalders/git-helpers
Turns https://github.com/oalders/git-helpers.git into https://github.com/oalders/git-helpers
Defaults to using
originas the remote if none is supplied.
Defaults to master branch, but can also display current branch.
my $current_branch_url = https_remote_url( 'origin', 1 );
Returns an arrayref of files which exist in your checkout, but are ignored by Git. Optionally accepts a directory as an argument. Defaults to ".".
Throws an exception if there has been an error running the command.
git rev-parse --is-inside-work-treereturns
true. Otherwise returns
false. This differs slightly from the behaviour of
--is-inside-work-treein real life, since it returns
falseif run outside of a git repository.
Returns a URL for the remote you've requested by name. Defaults to 'origin'. Provides you with the exact URL which git returns. Nothing is fixed up for you.
# defaults to 'origin' my $remote_url = remote_url(); # $remote_url is now possibly something like one of the following: # firstname.lastname@example.org:oalders/git-helpers.git # https://github.com/oalders/git-helpers.git # get URL for upstream remote my $upstream_url = remote_url('upstream');
Olaf Alders <email@example.com>
This software is copyright (c) 2015 by Olaf Alders.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.