summaryrefslogtreecommitdiff
path: root/lib/API/GitForge/GitLab.pm
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-03-10 09:21:48 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-03-10 09:21:48 -0700
commit564d3843d45fdd9dc53bd5147c7ca0d1b9fa9734 (patch)
treea3f13472fba5d7da863c8107691a071c5b8a1a30 /lib/API/GitForge/GitLab.pm
parent4ffcc33ad10f2cc5de517b80da24dd62bcacda87 (diff)
parentca1af5ff75521b8f2071642335858f464a7f221d (diff)
downloadp5-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/GitLab.pm')
-rw-r--r--lib/API/GitForge/GitLab.pm14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm
index 3f38bf7..1e620d8 100644
--- a/lib/API/GitForge/GitLab.pm
+++ b/lib/API/GitForge/GitLab.pm
@@ -113,13 +113,9 @@ sub _clean_config_fork {
sub _ensure_repo {
my ($self, $target) = @_;
my ($ns, $repo) = _extract_project_id($target);
-
- # first we are required to get the namespace id
+ return if $self->{_api}->project($target);
my $namespace = $self->{_api}->namespace($ns)
or croak "invalid project namespace $ns";
-
- # now create the project unless it already exists
- return if $self->{_api}->project($target);
$self->{_api}
->create_project({ name => $repo, namespace_id => $namespace->{id} });
}
@@ -132,6 +128,14 @@ sub _nuke_fork {
$self->{_api}->delete_project("$user/$repo");
}
+sub _ensure_fork_branch_unprotected {
+ my ($self, $upstream, $branch) = @_;
+ my (undef, $repo) = _extract_project_id($upstream);
+ my $user = $self->{_api}->current_user->{username};
+ return unless $self->{_api}->protected_branch("$user/$repo", $branch);
+ $self->{_api}->unprotect_branch("$user/$repo", $branch);
+}
+
sub _extract_project_id {
my $project = shift;
$project =~ s#(?:\.git)?/?$##;