Skip to content

Suggestion for Pad and Git modules #668

@halfminami

Description

@halfminami

The pad currently does not support branch: and commit: specifiers in Git modules and always fetches the main branch.
I am happy with it, however I can't seem to find explicit documentation stating that the pad always tries main.

I propose one of the following:

  1. Mention that main is always used in the pad at Modules tutorial, or
  2. Implement branch: and leave commit: unimplemented, or
  3. Implement both branch: and commit: (looks complex).

I can submit a PR for (1), (2), or (3) if this is something you'd like to see.

Why?

I initially wanted to load lib.ua on GitHub Gist in the pad (and later found that it wasn't so easy).

While trying, I loaded every module in Uiua modules inside the pad and noticed that amatgil/steal-gift throws an error with 404.
This is because the repository uses master branch instead of main, which wasn't obvious to me until I checked the code.

Looking at the source code, I found:

  • main is hardcoded like this, but modifying it to use a variable like other URL elements should not be so difficult.
    This would allow branch: support.
  • If commit: were to be implemented, it would need to fetch something like commits API to obtain tree.sha first.
    This would be a complex change.

    I realized I can use commit hash in place of branch name
  • (Question) I'm not sure what this line does.
    .replace("src/branch/master", "raw/branch/master");

    It contains master, but I couldn't find a case that triggers this replace.
    I think this line could be removed.

Summary

I propose updating the docs to state that the pad always fetches main branch.
I also found a way to support branch:, if that's of interest.

Afterthoughts: I forgot that this was specific to GitHub. If these changes are to be included, the document should also state it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions