From 13acc617af28a4374f13497e0401ef3937af5e86 Mon Sep 17 00:00:00 2001 From: gabrie30 Date: Sat, 31 Dec 2022 11:28:16 -0800 Subject: [PATCH] Update gitlab path trim prefix if not all-groups (#268) * Update gitlab path trim prefix if not all-groups --- CHANGELOG.md | 10 ++++++++++ cmd/version.go | 2 +- scm/gitlab.go | 11 +++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e3637c..8f540c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) + +## [1.9.2] - 12/31/22 +### Added +### Changed +### Deprecated +### Removed +### Fixed +- GitLab nested group names; thanks @MaxG87 +### Security + ## [1.9.1] - 12/11/22 ### Added - Ability to clone all users repos on hosted GitLab instances; thanks @mlaily diff --git a/cmd/version.go b/cmd/version.go index c0c7107..a87ad06 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/cobra" ) -const ghorgVersion = "v1.9.1" +const ghorgVersion = "v1.9.2" var versionCmd = &cobra.Command{ Use: "version", diff --git a/scm/gitlab.go b/scm/gitlab.go index cf6d15e..08c8262 100644 --- a/scm/gitlab.go +++ b/scm/gitlab.go @@ -13,8 +13,9 @@ import ( ) var ( - _ Client = Gitlab{} - perPage = 100 + _ Client = Gitlab{} + perPage = 100 + gitLabAllGroups = false ) func init() { @@ -41,6 +42,7 @@ func (c Gitlab) GetOrgRepos(targetOrg string) ([]Repo, error) { } if targetOrg == "all-groups" { + gitLabAllGroups = true longFetch = true grps, err := c.GetTopLevelGroups() @@ -297,9 +299,10 @@ func (c Gitlab) filter(group string, ps []*gitlab.Project) []Repo { path := p.PathWithNamespace - // For GitLab Cloud, the PathWithNamespace includes the org/group name + // The PathWithNamespace includes the org/group name // https://github.com/gabrie30/ghorg/issues/228 - if os.Getenv("GHORG_SCM_BASE_URL") == "" { + // https://github.com/gabrie30/ghorg/issues/267 + if !gitLabAllGroups { path = strings.TrimPrefix(path, group) }