Repository: lindell/multi-gitter (go)

Issue:
Gitlab: Does not support nested groups
**Describe the bug**
When using the `project` attribute in the yaml config or on the command line it does not support sub-groups on GitLab.

When running a config that has: 

```yaml
project:
  - group-org/subgroup/project
```

It fails with the following message:

`could not parse repository reference: group-org/subgroup/project`

Looking through the code it seems that it fails on this validation function:

https://github.com/lindell/multi-gitter/blob/cb4701eb90b98bf585b1a8835368c4cd8f0e0095/internal/scm/gitlab/gitlab.go#L70-L80

It splits on slashes and errors when the parts are not equal to `2`.

Changing the second slash to URI encoded slash (`group-org/subgroup%2Fproject`) allows me to pass the validation function but then it errors when actually trying to fetch the repository.

**Expected behavior**
I'd expect it to allow projects in nested groups on Gitlab.

Hope this is clear enough! Nice tool BTW! 👍🏾 


Pull request:
fix: added support for GitLab subgroups with --project
Closes #170 

Patch:
diff --git a/internal/scm/gitlab/gitlab.go b/internal/scm/gitlab/gitlab.go
index 53509fd..3ec6314 100644
--- a/internal/scm/gitlab/gitlab.go
+++ b/internal/scm/gitlab/gitlab.go
@@ -69,13 +69,13 @@ type ProjectReference struct {
 
 // ParseProjectReference parses a repository reference from the format "ownerName/repoName"
 func ParseProjectReference(val string) (ProjectReference, error) {
-	split := strings.Split(val, "/")
-	if len(split) != 2 {
+	lastSlashIndex := strings.LastIndex(val, "/")
+	if lastSlashIndex == -1 {
 		return ProjectReference{}, fmt.Errorf("could not parse repository reference: %s", val)
 	}
 	return ProjectReference{
-		OwnerName: split[0],
-		Name:      split[1],
+		OwnerName: val[:lastSlashIndex],
+		Name:      val[lastSlashIndex+1:],
 	}, nil
 }
 


Test patch:
diff --git a/internal/scm/gitlab/gitlab_test.go b/internal/scm/gitlab/gitlab_test.go
new file mode 100644
index 0000000..98edacc
--- /dev/null
+++ b/internal/scm/gitlab/gitlab_test.go
@@ -0,0 +1,57 @@
+package gitlab
+
+import (
+	"reflect"
+	"testing"
+)
+
+func TestParseProjectReference(t *testing.T) {
+	tests := []struct {
+		name    string
+		val     string
+		want    ProjectReference
+		wantErr bool
+	}{
+		{
+			name: "single",
+			val:  "my-group/my-project",
+			want: ProjectReference{
+				OwnerName: "my-group",
+				Name:      "my-project",
+			},
+		},
+		{
+			name: "subgroup",
+			val:  "my-group/sub-group/my-project",
+			want: ProjectReference{
+				OwnerName: "my-group/sub-group",
+				Name:      "my-project",
+			},
+		},
+		{
+			name: "two subgroups",
+			val:  "my-group/sub-group1/sub-group2/my-project",
+			want: ProjectReference{
+				OwnerName: "my-group/sub-group1/sub-group2",
+				Name:      "my-project",
+			},
+		},
+		{
+			name:    "no-group",
+			val:     "my-project",
+			wantErr: true,
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			got, err := ParseProjectReference(tt.val)
+			if (err != nil) != tt.wantErr {
+				t.Errorf("ParseProjectReference() error = %v, wantErr %v", err, tt.wantErr)
+				return
+			}
+			if !reflect.DeepEqual(got, tt.want) {
+				t.Errorf("ParseProjectReference() = %v, want %v", got, tt.want)
+			}
+		})
+	}
+}