diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-03-09 12:18:11 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-03-09 12:18:11 -0700 |
commit | a5db6b2e61deb66fc31bc2cc6c9e405081522a00 (patch) | |
tree | 7afb6582e4bfbd70a6d86ad04d8beffb65b564fe | |
parent | 87b20713db75d7b021d96298ac6c0d2dbab8cf2a (diff) | |
parent | a7b92281eaa19d1d2e36c7d0fd4d1359a2469e99 (diff) | |
download | p5-API-GitForge-a5db6b2e61deb66fc31bc2cc6c9e405081522a00.tar.gz |
Merge tag 'v0.002' into debian
v0.002
# gpg: Signature made Mon 09 Mar 2020 12:17:55 PM 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
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Changes | 7 | ||||
-rw-r--r-- | dist.ini | 7 | ||||
-rw-r--r-- | lib/API/GitForge/GitLab.pm | 28 | ||||
-rw-r--r-- | lib/API/GitForge/Role/GitForge.pm | 4 |
5 files changed, 38 insertions, 9 deletions
@@ -1 +1,2 @@ /API-GitForge-* +/.build @@ -2,5 +2,12 @@ Revision history for API::GitForge {{$NEXT}} +0.002 2020-03-09 12:17:47-07:00 America/Phoenix + - Implement API::GitForge::GitLab::_ensure_repo(). + - Add git repo metadata to dist.ini. + - Don't disable merge requests in GitLab clean forks. + Otherwise we can't submit merge requests upstream. + - Code cleanup. + 0.001 2020-02-16 16:20:35-07:00 America/Phoenix - First public release. @@ -4,7 +4,7 @@ license = GPL_3 copyright_holder = Sean Whitton <spwhitton@spwhitton.name> copyright_year = 2017, 2020 -version = 0.001 +version = 0.002 [PkgVersion] [PodWeaver] @@ -26,3 +26,8 @@ signoff = 1 [AutoPrereqs] [Prereqs] perl = 5.028 + +[MetaResources] +repository.url = https://git.spwhitton.name/p5-API-GitForge +repository.web = https://git.spwhitton.name/p5-API-GitForge +repository.type = git diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index 7ffd844..3f38bf7 100644 --- a/lib/API/GitForge/GitLab.pm +++ b/lib/API/GitForge/GitLab.pm @@ -70,12 +70,11 @@ sub _ensure_fork { sub _assert_fork_has_parent { my ($self, $upstream) = @_; - my (undef, $repo) = _extract_project_id($upstream); + my ($path, $repo) = _extract_project_id($upstream); my $user = $self->{_api}->current_user->{username}; my $fork = $self->{_api}->project("$user/$repo"); - $upstream =~ s/\.git$//; - $fork->{forked_from_project}{path_with_namespace} eq $upstream + $fork->{forked_from_project}{path_with_namespace} eq $path . "/" . $repo or croak "$user/$repo does not have parent $upstream; don't know what to do"; } @@ -101,15 +100,28 @@ sub _clean_config_fork { $self->{_api}->edit_project( "$user/$repo", { - default_branch => "gitforge", - description => "Temporary fork for merge request(s)", + 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", }); - - $self->_clean_config_repo("$user/$repo"); } sub _ensure_repo { - die "unimplemented"; + my ($self, $target) = @_; + my ($ns, $repo) = _extract_project_id($target); + + # first we are required to get the namespace id + 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} }); } sub _nuke_fork { diff --git a/lib/API/GitForge/Role/GitForge.pm b/lib/API/GitForge/Role/GitForge.pm index 933b166..bacc293 100644 --- a/lib/API/GitForge/Role/GitForge.pm +++ b/lib/API/GitForge/Role/GitForge.pm @@ -126,6 +126,10 @@ sub clean_fork { $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 + # 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. |