API-GitForge
view release on metacpan or search on metacpan
lib/API/GitForge/GitLab.pm view on Meta::CPAN
});
}
sub _clean_config_fork {
my ($self, $upstream) = @_;
my (undef, $repo) = _extract_project_id($upstream);
my $user = $self->{_api}->current_user->{username};
$self->{_api}->edit_project(
"$user/$repo",
{
default_branch => "gitforge",
description => "Temporary fork for merge request(s)",
issues_access_level => "disabled",
# merge requests have to be enabled in the fork in order
# to submit merge requests to the upstream repo from which
# we forked, it seems
merge_requests_access_level => "enabled",
});
}
sub _ensure_repo {
my ($self, $target) = @_;
my ($ns, $repo) = _extract_project_id($target);
return if $self->{_api}->project($target);
my $namespace = $self->{_api}->namespace($ns)
or croak "invalid project namespace $ns";
$self->{_api}
->create_project({ name => $repo, namespace_id => $namespace->{id} });
}
sub _nuke_fork {
my ($self, $upstream) = @_;
$self->_assert_fork_has_parent($upstream);
my (undef, $repo) = _extract_project_id($upstream);
my $user = $self->{_api}->current_user->{username};
$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)?/?$##;
$project =~ m#/([^/]+)$#;
($`, $1);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
API::GitForge::GitLab - common git forge operations using the GitLab API
=head1 VERSION
version 0.007
=head1 DESCRIPTION
See L<API::GitForge> and L<API::GitForge::Role::GitForge> for how to
use this class.
=head1 AUTHOR
Sean Whitton <spwhitton@spwhitton.name>
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2017, 2020 by Sean Whitton <spwhitton@spwhitton.name>.
This is free software, licensed under:
The GNU General Public License, Version 3, June 2007
=cut
( run in 0.307 second using v1.01-cache-2.11-cpan-70e19b8f4f1 )