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

Add 'tag_pattern' feature to git dependencies #4427

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sigurdm
Copy link
Contributor

@sigurdm sigurdm commented Nov 15, 2024

Re: #1250

With this proposal you can use a git repo as a versioned package repository.

For example write:

dependencies:
  foo:
    git:
      url: https://github.com/foo/foo
      tag_pattern: v*
    version: ^2.0.0

And all commits in the git repo that are tagged according to v* will be inspected. If they contain a pubspec.yaml with name: foo they will be considered for resolution.

The tag_pattern syntax is the one used by git tag --list. See https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---list

This feature is explicitly opt-in:

  • any git dependency without a tag_pattern retain the existing behavior.
  • The depending pubspec need to be at least at version 3.7.0

Open questions:

  • Should we forbid mixing the two kinds (ref-based and tag_pattern-based) of git-dependencies within a single resolution?
  • ...

case final String descriptionTagPattern:
tagPattern = descriptionTagPattern;
case null:
tagPattern = 'v*';
Copy link
Member

@jonasfj jonasfj Nov 15, 2024

Choose a reason for hiding this comment

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

Just wondering, if we should support multiple patterns, and if we should then default to two:

            tagPatterns = ['v*', '$package-v*'];

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm - considering this again I think we should actually not default to anything. I think it is probably better to be unopinionated here

Comment on lines 982 to 983
'tag_pattern': description.tagPattern,
'resolved-ref': resolvedRef,
Copy link
Member

@jonasfj jonasfj Nov 15, 2024

Choose a reason for hiding this comment

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

Should we use tag-pattern for consistency? (it would be inconsistent with other fields in pubspec.yaml).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm - this is pubspec.lock.
In pubspec.yaml we use _ (at least in pubspec_overrides and dev_dependencies.

So when we copy the field from the pubspec.yaml to pubspec.lock it is confusing if we change the spelling.

At the same time it is confusing that we have resolved-ref in the pubspec.lock.

Can we find a single-word alternative?

@@ -72,6 +75,32 @@ class GitSource extends CachedSource {
'string.');
}
path = descriptionPath;

// TODO: can we avoid relying on key presence?
if (description.containsKey('tag_pattern')) {
Copy link
Member

Choose a reason for hiding this comment

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

What about simply using tags and then support one or more patterns?

dependencies:
  foo:
    git:
      url: https://foo.bar.git/repo
      tags: v*

and

dependencies:
  foo:
    git:
      url: https://foo.bar.git/repo
      tags:
       - v*
       - foo-v*

or maybe not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah - that might work

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.

2 participants