Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Namespace in GitLab is wrong #48

Open
odg0318 opened this issue Nov 25, 2019 · 0 comments
Open

Namespace in GitLab is wrong #48

odg0318 opened this issue Nov 25, 2019 · 0 comments

Comments

@odg0318
Copy link

odg0318 commented Nov 25, 2019

Hello. I have an issue in GitLab repository.

Some repositories in my GitLab belong to sub-group, such as foo/bar/baz/sample.
In this case, sample is project name and foo/bar/baz is namespace in my opinion.
But actually only baz is parsed as namespace via this code.

Related codes are below.
https://github.com/drone/go-scm/blob/master/scm/driver/gitlab/repo.go#L172

func convertRepository(from *repository) *scm.Repository {
	to := &scm.Repository{
		ID:        strconv.Itoa(from.ID),
		Namespace: from.Namespace.Path,
		Name:      from.Path,
		Branch:    from.DefaultBranch,
		Private:   convertPrivate(from.Visibility),
		Clone:     from.HTTPURL,
		CloneSSH:  from.SSHURL,
		Perm: &scm.Perm{
			Pull:  true,
			Push:  canPush(from),
			Admin: canAdmin(from),
		},
	}
	if to.Namespace == "" {
		if parts := strings.SplitN(from.PathNamespace, "/", 2); len(parts) == 2 {
			to.Namespace = parts[1]
		}
	}
	return to
}

As I know, Drone also uses this drone/scm project to communicate various kinds of repositories. And the above issue makes some errors to sync GitLab repository.

GitLab response of foo/bar/baz/sample project is as below.

[
  {
    "id": 1000,
    "name": "sample",
    "path": "sample",
    "path_with_namespace": "foo/bar/baz/sample",
    "namespace": {
      "id": 256,
      "name": "baz",
      "path": "baz",
      "kind": "group",
      "full_path": "foo/bar/baz",
      "parent_id": 14
    },

I suggest that namespace.full_path is used as namespace property.

Reference: https://discourse.drone.io/t/drone-cannot-parse-sub-group-project-path/6361

jstrachan pushed a commit to jstrachan/go-scm that referenced this issue Dec 22, 2020
fix: add API to query an App repository installation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant