diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-03-10 09:21:48 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-03-10 09:21:48 -0700 |
commit | 564d3843d45fdd9dc53bd5147c7ca0d1b9fa9734 (patch) | |
tree | a3f13472fba5d7da863c8107691a071c5b8a1a30 /lib/API/GitForge/Role/GitForge.pm | |
parent | 4ffcc33ad10f2cc5de517b80da24dd62bcacda87 (diff) | |
parent | ca1af5ff75521b8f2071642335858f464a7f221d (diff) | |
download | p5-API-GitForge-564d3843d45fdd9dc53bd5147c7ca0d1b9fa9734.tar.gz |
Merge tag 'v0.003' into debian
v0.003
# gpg: Signature made Tue 10 Mar 2020 09:21:35 AM MST
# gpg: using RSA key 9B917007AE030E36E4FC248B695B7AE4BF066240
# gpg: issuer "spwhitton@spwhitton.name"
# gpg: Good signature from "Sean Whitton <spwhitton@spwhitton.name>" [ultimate]
# Primary key fingerprint: 8DC2 487E 51AB DD90 B5C4 753F 0F56 D055 3B6D 411B
# Subkey fingerprint: 9B91 7007 AE03 0E36 E4FC 248B 695B 7AE4 BF06 6240
Diffstat (limited to 'lib/API/GitForge/Role/GitForge.pm')
-rw-r--r-- | lib/API/GitForge/Role/GitForge.pm | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/lib/API/GitForge/Role/GitForge.pm b/lib/API/GitForge/Role/GitForge.pm index bacc293..52760ff 100644 --- a/lib/API/GitForge/Role/GitForge.pm +++ b/lib/API/GitForge/Role/GitForge.pm @@ -26,7 +26,7 @@ Operations which one might wish to perform against any git forge. See L<API::GitForge>. In this documentation, C<example.com> should be replaced with the -domain at which your GitForge is hosted, e.g. C<salsa.debian.org>. +domain at which your git forge is hosted, e.g. C<salsa.debian.org>. =cut @@ -104,14 +104,13 @@ fork suitable for adding as a git remote. sub clean_fork { my $self = shift; - my $fork_uri = $self->_ensure_fork(@_); + my $fork_uri = $self->_ensure_fork($_[0]); my $temp = tempdir CLEANUP => 1; my $git = Git::Wrapper->new($temp); $git->init; - $git->remote(qw(add fork), $fork_uri); my @fork_branches - = map { m#refs/heads/#; $' } $git->ls_remote(qw(--heads fork)); + = map { m#refs/heads/#; $' } $git->ls_remote("--heads", $fork_uri); return $fork_uri if grep /\Agitforge\z/, @fork_branches; open my $fh, ">", catfile $temp, "README.md"; @@ -120,19 +119,15 @@ sub clean_fork { $git->add("README.md"); $git->commit({ message => "Temporary fork for pull request(s)" }); - # TODO why does Git::Wrapper hang after pushing the branch to - # GitLab? for now, just use system() to do the push ourselves - system "git", "-C", $git->dir, "push", $fork_uri, "master:gitforge"; - - $self->_clean_config_fork(@_); - - # TODO use API to unprotect all branches in the fork. we still - # want to use git-push(1) to delete the branches, rather than - # using the API for that, because that's maximally compatible + $git->push($fork_uri, "master:gitforge"); + $self->_clean_config_fork($_[0]); # assume that if we had to create the gitforge branch, we just # created the fork, so can go ahead and nuke all branches there. - # may fail if some branches are protected; that's okay. + if ($self->can("_ensure_fork_branch_unprotected")) { + $self->_ensure_fork_branch_unprotected($_[0], $_) for @fork_branches; + } + # may fail if we couldn't unprotect; that's okay eval { $git->push($fork_uri, "--delete", @fork_branches) }; return $fork_uri; |