From 3e1470578aa7305e1f091dadf9b64f93f983f147 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 16 Feb 2020 17:40:55 -0700 Subject: Add git repo metadata to dist.ini Signed-off-by: Sean Whitton --- Changes | 1 + dist.ini | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/Changes b/Changes index aab2a56..d2c7f73 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for API::GitForge {{$NEXT}} + - Add git repo metadata to dist.ini. 0.001 2020-02-16 16:20:35-07:00 America/Phoenix - First public release. diff --git a/dist.ini b/dist.ini index 93c373b..f83a23c 100644 --- a/dist.ini +++ b/dist.ini @@ -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 -- cgit v1.2.3 From 03ae097e2fc526586eb5c409c325e6bb1caad52f Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 17 Feb 2020 17:28:42 -0700 Subject: Don't disable merge requests in GitLab clean forks Signed-off-by: Sean Whitton --- Changes | 2 ++ lib/API/GitForge/GitLab.pm | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index d2c7f73..0c15594 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,8 @@ Revision history for API::GitForge {{$NEXT}} - Add git repo metadata to dist.ini. + - Don't disable merge requests in GitLab clean forks, otherwise we + can't submit merge requests upstream. 0.001 2020-02-16 16:20:35-07:00 America/Phoenix - First public release. diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index 7ffd844..b264eb9 100644 --- a/lib/API/GitForge/GitLab.pm +++ b/lib/API/GitForge/GitLab.pm @@ -101,11 +101,14 @@ 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 { -- cgit v1.2.3 From 76ccdf33280379b26ec745def5edceb28043d925 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 17 Feb 2020 18:19:03 -0700 Subject: don't drop .git from $upstream in two places Signed-off-by: Sean Whitton --- lib/API/GitForge/GitLab.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index b264eb9..12d318b 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"; } -- cgit v1.2.3 From 00a5902b22ba9a82b4113f97f23f6fd8d9e93858 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 17 Feb 2020 18:19:32 -0700 Subject: changelog Signed-off-by: Sean Whitton --- Changes | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 0c15594..1f4e1f1 100644 --- a/Changes +++ b/Changes @@ -2,8 +2,9 @@ Revision history for API::GitForge {{$NEXT}} - Add git repo metadata to dist.ini. - - Don't disable merge requests in GitLab clean forks, otherwise we - can't submit merge requests upstream. + - 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. -- cgit v1.2.3 From e8500273c206df871c82a72b4824b9174067d58b Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 17 Feb 2020 19:22:25 -0700 Subject: add TODO Signed-off-by: Sean Whitton --- lib/API/GitForge/Role/GitForge.pm | 4 ++++ 1 file changed, 4 insertions(+) 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. -- cgit v1.2.3 From afc3605111d32c1eb59711f0d8c7f4ce0bfc7d05 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Thu, 20 Feb 2020 10:58:52 -0700 Subject: add TODO Signed-off-by: Sean Whitton --- lib/API/GitForge/GitLab.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index 12d318b..f4baaad 100644 --- a/lib/API/GitForge/GitLab.pm +++ b/lib/API/GitForge/GitLab.pm @@ -111,6 +111,7 @@ sub _clean_config_fork { } sub _ensure_repo { + # TODO die "unimplemented"; } -- cgit v1.2.3 From 6545565d13b6748057f632ea1834f21e722f8a79 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 24 Feb 2020 07:39:40 -0700 Subject: add .build to .gitignore Signed-off-by: Sean Whitton --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9a4de91..085022c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /API-GitForge-* +/.build -- cgit v1.2.3 From 198451435d669e388e5963fe0667e0460b8c75dc Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 9 Mar 2020 12:11:12 -0700 Subject: Implement API::GitForge::GitLab::_ensure_repo() Signed-off-by: Sean Whitton --- Changes | 1 + lib/API/GitForge/GitLab.pm | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index 1f4e1f1..41ade93 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for API::GitForge {{$NEXT}} + - 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. diff --git a/lib/API/GitForge/GitLab.pm b/lib/API/GitForge/GitLab.pm index f4baaad..3f38bf7 100644 --- a/lib/API/GitForge/GitLab.pm +++ b/lib/API/GitForge/GitLab.pm @@ -111,8 +111,17 @@ sub _clean_config_fork { } sub _ensure_repo { - # TODO - 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 { -- cgit v1.2.3 From cf650e4fc3cd47bceb669126e8d1b4e5a056a41e Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 9 Mar 2020 12:17:24 -0700 Subject: bump version Signed-off-by: Sean Whitton --- dist.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist.ini b/dist.ini index f83a23c..cd333e1 100644 --- a/dist.ini +++ b/dist.ini @@ -4,7 +4,7 @@ license = GPL_3 copyright_holder = Sean Whitton copyright_year = 2017, 2020 -version = 0.001 +version = 0.002 [PkgVersion] [PodWeaver] -- cgit v1.2.3 From a7b92281eaa19d1d2e36c7d0fd4d1359a2469e99 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 9 Mar 2020 12:17:55 -0700 Subject: v0.002 - 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. Signed-off-by: Sean Whitton --- Changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changes b/Changes index 41ade93..5f6e9bf 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ 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. -- cgit v1.2.3