Drone

[Gitlab] Workaround for subgroups

Drone not supporting Gitlab subgroups was a dealbreaker for us.
So, I created a workaround for it : Mrigank11/go-scm@589b3b4

Basically, for any repo abc/def/project, I’m storing it on drone as Namespace: abc--def and Name:project. It’s solves our problem.

What do you guys think?
If it’s good enough to merge, I’ll clean it up and send a PR.

:wave: hey there, thanks for taking the time to look at the code and come up with some options. unfortunately this is not something we would merge, which I will try and explain below.

The first reason is that the go-scm library works fine with subgroups. The problem is not with the go-scm library, the problem is with Drone core. If we were to consider implementing a workaround, it would be in Drone, not in go-scm.

The second reason is this approach (replacing / with -) could have unintended consequences. I would be concerned with repository name collisions which can have security implications. For example, image we have a repository called foo-bar/baz and subgroup foo/bar/baz.

The proposed workaround would also cause issues with displays being incorrect in the user interface, when sending slack notifications (and many other plugins), using the command line utility, etc. While some people may be willing to accept these inconsistencies, other will not, and as the maintainer I will be stuck responding to forum posts and github issues claiming Drone is broken. This is not something I am willing to commit to.

For these reasons, if we are going to support subgroups in Drone, we need proper support as opposed to a workaround.

Thank you for the explanation but I still think we can make subgroups work without major changes in the code.

The first reason is that the go-scm library works fine with subgroups.

I disagree. Consider two repositories: foo/bar/baz and bar/baz.
Currently, go-scm will identify both of them as same because it’s settings namespace using the path property instead of full_path (See repo.go#L175 and Gitlab API)

The second reason is this approach (replacing / with -)

How about I make some more changes to use / as the separator instead of --?
Basically, in case of subgroups, namespace will be everything before repo name. For example: in case of foo/bar/baz, Namespace = foo/bar and RepoName = baz

Do you think that’ll solve all the issues? I’d be happy to work on it.

The ideal solution for foo/bar/baz would be namespace foo and repository bar/baz. It will require significant development effort to get this working because it touches almost every layer of Drone.