Pub: Add `path` option to git dependencies

Created on 27 Jul 2015  路  15Comments  路  Source: dart-lang/pub

Today you can do:

dependencies:
  my_package:
    git:
      ref: my_branch
      url: https://github.com/username/repo_name.git

It is assumed the path lives at the root of the repo. I propose an additional path option, which allows you to specify a path to the root of the package inside the specified repo.

enhancement

Most helpful comment

All 15 comments

Duplicate of #1036. I still think there should be a one-to-one correspondence between repositories and packages. Also, this goes against Git's general philosophy of not allowing a repository to be checked out or committed to on a subdirectory basis.

I still think there should be a one-to-one correspondence between repositories and packages.

I agree with this as a guideline, but not as a rule. There are plenty of situations in which it doesn't make sense for the package to live at the root directory. For instance if angular2 wanted to start checking in the dart code to their repo to enable git dependencies, it certainly wouldn't live in the root dir. I am sure there are also teams out there who would rather develop all their packages in one repo, and that shouldn't remove the possibility of using a git dependency.

Also, this goes against Git's general philosophy of not allowing a repository to be checked out or committed to on a subdirectory basis.

Couldn't pub check out the entire repo and just point the symlink at the subdir? That would be a bit wasteful in terms of bandwidth/disk space but it probably doesn't matter, its just the cost you pay to use this feature. Either way my assumption would be that you would never be commiting to this repo, and pub is just using git as a delivery mechanism for the code so I don't think its important to follow any particular standards.

I'm still not a fan, but I know @rnystrom was also pushing for this. If he wants to implement it, I'll accept a patch.

Here are the git commands to grab a subdirectory of a remote git repository:

git init .
git fetch <repo> <refspec>
git ls-tree FETCH_HEAD <path>

this will return a line that looks like
040000 tree ABCDEF
where ABCDEF is the sha1 of the tree object. To check that out then do

git read-tree <sha1>
git checkout-index -a

That reads the sha1 into the index and then checks the index out to disk. You might want to reset --hard / clean -fd as well to make sure no other local files are sitting around.

I heard that an offline conversation mentioned that @nex3 would accept a patch (along with the comment from https://github.com/dart-lang/pub/issues/1305#issuecomment-125732930), so I'd like to reopen this. I know that @jamesr is keen to work on this patch (hence, his questions about how to build and test pub), so reopening would be a nice signal.

Would that be OK to reopen, @nex3 ?

Sure.

Thanks!

@sethladd, @jamesr : any progress on that patch?

Nothing from where I sit.

It turns out this isn't useful for what we had in mind so I haven't pursued this further.

It's likely this will become relevant again soon, but no pressing need.

Official Flutter plugins are all hosted in single git repository under packages/<name> (https://github.com/flutter/plugins).

I've submitted a PR a few days ago for google_sign_in and using local path in my pubspec for now, waiting for PR to get merged and published.

This is basically blocking me to push my changes since it'll break my CI build.

If pub supported nested packages I could just reference my fork of Flutter plugins to get the latest changes.

@pulyaevskiy you might be able to work around this using a git submodule/subtree and a path dependency.

However, I'd love to have paths be supported in pub git dependencies; it would make forking first-party plugins and upstreaming changes much easier.

@collinjackson I was hoping to avoid it :) but yes it's an option.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Atulin picture Atulin  路  4Comments

DartBot picture DartBot  路  3Comments

AhmedAlaa96 picture AhmedAlaa96  路  6Comments

henryejemuta picture henryejemuta  路  5Comments

jimsimon picture jimsimon  路  5Comments