Skip to content

Commit

Permalink
fork: fix clonning for projects within subgroups
Browse files Browse the repository at this point in the history
Projects placed within a subgroup in gitlab was not being cloned while using
'fork' cmd. Even though the project was being properly forked in gitlab, the
issue was that only the first path part (after namespace) was being used as the
project name to be clone from user's namespace, e.g.  'user/group/project' was
being handled by lab as a project with name 'group' instead of 'project'.  This
patch uses the last path part always, regardless the project being placed
within a group or not.

Signed-off-by: Bruno Meneguele <bmeneg@redhat.com>
  • Loading branch information
bmeneg committed Sep 9, 2020
1 parent f8306df commit d4dfe5e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/fork.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ func forkToUpstream(cmd *cobra.Command, args []string) {
log.Fatal(err)
}
if !skipClone {
cloneCmd.Run(nil, []string{strings.Split(args[0], "/")[1]})
projectParts := strings.Split(args[0], "/")
// In case many subgroups are used, the project's name forked will be
// the last index
projectName := projectParts[len(projectParts)-1]
cloneCmd.Run(nil, []string{projectName})
}
}
func determineForkRemote(project string) string {
Expand Down

0 comments on commit d4dfe5e

Please sign in to comment.