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

Does not work when branch name contains a '/' #16

Closed
Mukundan314 opened this issue Jul 1, 2020 · 4 comments
Closed

Does not work when branch name contains a '/' #16

Mukundan314 opened this issue Jul 1, 2020 · 4 comments

Comments

@Mukundan314
Copy link
Contributor

url tested with: https://gitlab.com/Mukundan314/test/-/blob/test/test/test.txt#L2

@Mukundan314
Copy link
Contributor Author

@Mukundan314 Mukundan314 changed the title Does not work when branch name contains a '/' in gitlab Does not work when branch name contains a '/' Jul 5, 2020
@dolphingarlic
Copy link
Owner

Do you know how many /s a branch name can have? The easiest solution I have in mind would just be to try all branch/file-path pairs, but that's quite inefficient. (I don't think there's a simple regex solution 😦)

@Mukundan314
Copy link
Contributor Author

I think we currently have three options

First Option: List branches of the repo

API to do this on GitHub: https://docs.github.com/en/rest/reference/repos#list-branches
API to do this on GitLab: https://docs.gitlab.com/ee/api/branches.html

Second Option: Manually construct raw url

In GitHub raw urls are of the form: https://raw.githubusercontent.com/<repo>/<ref>/<file_path>
In GitLab raw urls are of the form: https://gitlab.com/<repo>/-/raw/r<ref>/<file_path>

Since here ref and file_path are side-by-side we don't need to separate them in the regex.

Note: It will be hard to support private repos with this method

Third Option: Trying all branch/file-path pairs

Like you said this option is quite inefficient


IMO the first option is probably the most elegant I can create PR for the first option if you want.

@dolphingarlic
Copy link
Owner

It would be really great if you create a PR 😃

Could you maybe also add a test for this case?

Mukundan314 added a commit to Mukundan314/git-the-lines that referenced this issue Jul 6, 2020
dolphingarlic added a commit that referenced this issue Jul 6, 2020
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

2 participants