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

Gitlab subgroups doesn't seem to be supported #28

Closed
nesk opened this issue Sep 14, 2020 · 6 comments
Closed

Gitlab subgroups doesn't seem to be supported #28

nesk opened this issue Sep 14, 2020 · 6 comments
Labels
Projects

Comments

@nesk
Copy link

nesk commented Sep 14, 2020

I have a Gitlab remote URL with this format:

git@example.com:group/subgroup/repository.git

When trying, for example, to open a commit with the following command:

git-brws aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

The following URL is opened:

https://example.com/group/subgroup/commit/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

It seems like Gitlab subgroups aren't supported.

I'm not a Rust developer so I can't submit a reliable PR within reasonable time, however I've searched a bit and the issue comes from the slug_from_path function:

git-brws/src/service.rs

Lines 396 to 407 in 5a1c351

let mut split = path.split('/').skip_while(|s| s.is_empty());
let user = split.next().ok_or_else(|| {
Error::new(ErrorKind::NoUserInPath {
path: path.to_string(),
})
})?;
let mut repo = split.next().ok_or_else(|| {
Error::new(ErrorKind::NoRepoInPath {
path: path.to_string(),
})
})?;

Instead of considering the URL will be splitted in only two parts, you should use the last element of the iterator as the repository, and join all the other elements with / as the separator.

@rhysd
Copy link
Owner

rhysd commented Sep 17, 2020

I'm actually not a GitLab user. Would you tell me the expected behavior? What URL should be opened in the case?

I guess

https://example.com/group/subgroup/repository/commit/aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d

but I want to ensure.

@rhysd rhysd added the bug label Sep 17, 2020
@nesk
Copy link
Author

nesk commented Sep 17, 2020

Yes, this is the expected URL.

Github URLs contain only a group/user and a repository, meanwhile Gitlab URLs can contain multiple subgroups (/group/subgroup1/subgroup2/.../repository), this is the only difference.

If you want an example, here's one: https://gitlab.com/gitlab-com/alliances/google/sandbox-projects/gitlab-tweet-app
This repository is contained in the gitlab-com group and the following subgroups: alliances, google, sandbox-projects.

@rhysd
Copy link
Owner

rhysd commented Sep 17, 2020

OK, thank you for the clarification. We need to search the last slash for separating slug into owner and repository.

@rhysd
Copy link
Owner

rhysd commented Sep 17, 2020

@rhysd rhysd added this to Doing in git-brws Sep 17, 2020
@rhysd rhysd closed this as completed in 558043c Sep 18, 2020
@nesk
Copy link
Author

nesk commented Sep 18, 2020

Thank you so much! 🙏

@rhysd
Copy link
Owner

rhysd commented Sep 18, 2020

This fix was released at v0.11.12.

@rhysd rhysd moved this from Doing to Done in git-brws Sep 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

2 participants