Skip to content

feat(git): add support for :: in #committish#91

Merged
wraithgar merged 2 commits intomainfrom
gar/46
Jun 22, 2022
Merged

feat(git): add support for :: in #committish#91
wraithgar merged 2 commits intomainfrom
gar/46

Conversation

@wraithgar
Copy link
Copy Markdown
Member

@wraithgar wraithgar commented Jun 21, 2022

This builds off of #46, and
more specifically the spec laid out by @coreyfarrell. Namely:

For each :: separated item:

  • If the item has no : then it is a commit-ish
  • If the item has : then split into name and value.
    • If the name is semver then do semver lookup of ref or tag
    • If the name is path then use the value as the subdir to install from.
    • If the name is unknown then warn that the name-value pair is being ignored.

This loop errors if duplicate values are found.
Unknown values log a warning instead of erroring.

This also introduces the concept of a path specifier that is assigned
to the gitSubdir attribute. Consuming libs (e.g. pacote) will need to
look for that and react to its presence accordingly.

Credit: @sspiff for the original PR and @coreyfarrell for the spec

sspiff and others added 2 commits June 21, 2022 12:37
This iterates on the spec outlined by @coreyfarrel in
#46.

For each :: separated item:
  * If the item has no : then it is a commit-ish
  * If the item has : then split into name and value.
    * If the name is semver then do semver lookup of ref or tag
    * If the name is path then use the value as the subdir to install from.
    * If the name is unknown then warn that the name-value pair is being ignored.

This loop errors if duplicate values are found.
Unknown values log a warning instead of erroring.
@wraithgar wraithgar requested a review from a team as a code owner June 21, 2022 20:51
@wraithgar wraithgar added the Agenda will be discussed at the Open RFC call label Jun 21, 2022
Copy link
Copy Markdown
Contributor

@nlf nlf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@wraithgar wraithgar changed the title feat: feat(git): add support for :: in #committish feat(git): add support for :: in #committish Jun 22, 2022
@wraithgar wraithgar merged commit 246f1e9 into main Jun 22, 2022
@wraithgar wraithgar deleted the gar/46 branch June 22, 2022 20:42
@prmichaelsen
Copy link
Copy Markdown

ahhhhhh shieeeet

@darcyclarke darcyclarke removed the Agenda will be discussed at the Open RFC call label Jun 29, 2022
@Finesse
Copy link
Copy Markdown

Finesse commented Mar 14, 2025

NPM CLI doesn't support gitSubdir yet, does it?

wraithgar pushed a commit to npm/pacote that referenced this pull request Feb 6, 2026
This implements the `gitSubdir` parameter, which is already parsed by
npa, finally allowing users of npm to specifiy subdirectories in git
dependencies.

The respective parsing logic has already been agreed on and implemented
nearly 4 years ago here: npm/npm-package-arg#91.
In this PR, the git fetcher is changed to resolve the `gitSubdir`
parameter from the spec if found, as suggested by the author in the
original npa PR.

## References
Fixes npm/cli#528
Fixes npm/npm#2974
Relates to npm/npm-package-arg#46
Relates to  npm/npm-package-arg#91

Inspired from and crediting
sspiff@8bd5461,
which seems to have been lost after merging the PR at npa.
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

Successfully merging this pull request may close these issues.

6 participants