Skip to content

Commit

Permalink
gitlab: consider custom namespace for finding a project
Browse files Browse the repository at this point in the history
Prior effectively forking the project, consider the custom namespace for
searching if it already exists.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
  • Loading branch information
bmeneg committed Dec 17, 2020
1 parent 35edd30 commit 308d63a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions internal/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,22 @@ func Fork(data ForkStruct, useHTTP bool, wait bool) (string, error) {
}
parts := strings.Split(data.SrcProject, "/")

// See if a fork already exists
target, err := FindProject(parts[1])
// See if a fork already exists in the destination
name := parts[1]
namespace := ""
if data.isCustomTargetSet() {
if data.TargetNamespace != "" {
namespace = data.TargetNamespace + "/"
}
// Project name takes precedence over path for finding a project
// on Gitlab through API
if data.TargetName != "" {
name = data.TargetName
} else if data.TargetPath != "" {
name = data.TargetPath
}
}
target, err := FindProject(namespace + name)
if err == nil {
urlToRepo := target.SSHURLToRepo
if useHTTP {
Expand Down

0 comments on commit 308d63a

Please sign in to comment.