Audio-Nama
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Audio/Nama/Git.pm view on Meta::CPAN
# ---------- Git Support ----------
package Audio::Nama;
use Modern::Perl '2020';
sub git {
return if is_test_script();
$config->{use_git} or warn("@_: git command, but git is not enabled.
You may want to set use_git: 1 in .namarc"), return;
logpkg(__FILE__,__LINE__,'debug',"VCS command: git @_");
$project->{repo}->run(@_)
}
sub repo_git_dir { join_path(project_dir(),'.git') }
sub init_repo_obj { $project->{repo} = Git::Repository->new( work_tree => project_dir() ) }
sub create_repo { Git::Repository->run( init => project_dir() )}
sub initialize_project_repository {
logsub((caller(0))[3]);
Audio::Nama::throw("either a test script running or use_git: 0 is configured in .namarc. ",
"No repo created for project ", project_dir()),
return if not $config->{use_git} or is_test_script();
if (not -d repo_git_dir()){
pager("Creating git repository in ". repo_git_dir());
create_repo;
init_repo_obj();
create_file_stubs();
git_commit('initialize_repository');
} else {
init_repo_obj();
#git_commit('committing prior changes') if git_diff();
}
}
sub git_diff {
my @files = @_;
my $diff = git('diff', @files);
$diff =~ /\S/ ? $diff : undef
}
sub git_tag_exists {
logsub((caller(0))[3]);
my $tag = shift;
grep { $tag eq $_ } git( 'tag','--list');
}
# on command "get foo", Nama opens a branch name 'foo-branch',
# or returns to HEAD of existing branch 'foo-branch'
sub tag_branch { "$_[0]-branch" }
sub restore_state_from_vcs {
logsub((caller(0))[3]);
my $name = shift; # tag or branch
# checkout branch if matching branch exists
if (git_branch_exists($name)){
pager_newline( qq($name: branch exists. Checking out branch $name.) );
git_checkout($name);
}
# checkout branch diverging at tag if matching that tag
elsif ( git_tag_exists($name) ){
my $tag = $name;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.427 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )