Skip to content

Commit

Permalink
Merge pull request #602 from bmeneguele/fix-fork-findproject
Browse files Browse the repository at this point in the history
fix project lookup during fork
  • Loading branch information
bmeneg authored Feb 25, 2021
2 parents fac8ea2 + aafaffb commit 80edd01
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions internal/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,14 @@ func Fork(project string, opts *gitlab.ForkProjectOptions, useHTTP bool, wait bo
}
target, err := FindProject(namespace + name)
if err == nil {
// Check if it was forked from the same project being requested
if target.ForkedFromProject != nil &&
target.ForkedFromProject.PathWithNamespace != project {
errMsg := fmt.Sprintf("\"%s\" fork name already taken for a different project", name)
return "", errors.New(errMsg)
}

// Project already forked and found
urlToRepo := target.SSHURLToRepo
if useHTTP {
urlToRepo = target.HTTPURLToRepo
Expand Down

0 comments on commit 80edd01

Please sign in to comment.