Git Product home page Git Product logo

Comments (4)

Mukundan314 avatar Mukundan314 commented on May 20, 2024

same problem on GitHub too url tested with: https://github.com/cheran-senthil/PyRival/blob/feat/lazy-segment-tree-custom-add/pyrival/algebra/chinese_remainder.py#L16

from git-the-lines.

dolphingarlic avatar dolphingarlic commented on May 20, 2024

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 😦)

from git-the-lines.

Mukundan314 avatar Mukundan314 commented on May 20, 2024

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.

from git-the-lines.

dolphingarlic avatar dolphingarlic commented on May 20, 2024

It would be really great if you create a PR 😃

Could you maybe also add a test for this case?

from git-the-lines.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.