uiua icon indicating copy to clipboard operation
uiua copied to clipboard

Suggestion for Pad and Git modules

Open halfminami opened this issue 1 year ago • 0 comments

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. https://github.com/uiua-lang/uiua/blob/01c3bcd7c0a9badd91f89a5e6665a65ee1511b87/pad/editor/src/backend.rs#L464 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.

halfminami avatar Mar 01 '25 06:03 halfminami