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

Slash in revision name #104

Open
yaronya opened this issue Mar 4, 2020 · 5 comments
Open

Slash in revision name #104

yaronya opened this issue Mar 4, 2020 · 5 comments

Comments

@yaronya
Copy link

yaronya commented Mar 4, 2020

if there's a / in revision name (either for tag or branch) then url is parsed in a wrong manner and cuts the revision name from the existing /. so for e.g if branch name is feature/foo then git-url-parse would fetch the revision name as feature leaving /foo out.

@yaronya yaronya changed the title slash in revision name Slash in revision name Mar 4, 2020
@IonicaBizau
Copy link
Owner

Can you add an example?

@taras
Copy link

taras commented Oct 8, 2020

@IonicaBizau dependabot branches are a very good example: https://github.com/spotify/backstage/blob/dependabot/npm_and_yarn/testing-library/jest-dom-5.11.4/package.json

@taras
Copy link

taras commented Oct 8, 2020

I created a failing test #114

@jimmywarting
Copy link

jimmywarting commented Feb 18, 2023

it's possible to get all the branches from githubs api using: https://api.github.com/repos/node-fetch/node-fetch/branches

b/c the parsing is synchronous, i propose that you make it possible to pass in an option with all the branch names that are available...

Something like:

// const branches = await fetch('https://api.github.com/repos/node-fetch/node-fetch/branches')
//  .then(r => r.json()).then(j => j.map(e => e.name))

const branches = [
  "1.x",
  "2.x",
  "beta",
  "dependabot/npm_and_yarn/formdata-node-5.0.0",
  "dependabot/npm_and_yarn/mocha-10.2.0",
  "dependabot/npm_and_yarn/p-timeout-6.1.1",
  "dependabot/npm_and_yarn/tsd-0.25.0",
  "dependabot/npm_and_yarn/xo-0.53.1",
  "main"
]

const url = 'https://github.com/node-fetch/node-fetch/blob/dependabot/npm_and_yarn/p-timeout-6.1.1/.gitignore'

GitUrlParse(url, { branches })

Only if the user needs to get the branches in order to get the correct file path would they need to do this fetching more manually

then if the branch name can't be found in the list then it would just assume that the branch name dose not include any / and just pick the first one

@nimmi-exxcellent
Copy link

We recently ran into the same issue when using backstage (which internally uses git-url-parse) at our company. In some cases you can get around it by escaping the slash in the branch name e.g. dependabot/npm_and_yarn --> dependabot%2fnpm_and_yarn but unfortunately this library doesn't support it.

We would be willing to implement this feature and provide a PR. But first we want to make sure it is something you are interested in before we start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants