13

I have a couple of small dart demo projects together in one git repository. Thus each project is in a subfolder of the repository and the yaml files of each of these projects is in the corresponding folder, not under the root of the repo. Is there a way to specify a git dependency to such a subfolder within a git repo? I know that I can clone the repository manually and use a file path in the dependency specification. But what I'm looking for is a way to have a direct git url for that package in a subdir. Is this possible?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Gregor
  • 2,917
  • 5
  • 28
  • 50
  • 1
    have you tried to add the directory name to the URL? `git: url: git://github.com/munificent/kittens.git/somedir` The documentation only mentions `ref: some-branch` (The ref can be anything that Git allows to identify a commit) see https://www.dartlang.org/tools/pub/dependencies.html#git-packages – Günter Zöchbauer Jun 30 '14 at 13:21
  • This doesn't work, because pub triggers a git clone first, but the url with appended directory does not refer to a valid git repository and so the clone fails. – Gregor Jul 01 '14 at 07:38
  • I guess you should make a feature request dartbug.com/new – Günter Zöchbauer Jul 01 '14 at 08:02
  • 1
    I create a feature request. See https://code.google.com/p/dart/issues/detail?id=19797 – Gregor Jul 02 '14 at 14:20

2 Answers2

45

Several years on, support for this has been added:

https://github.com/dart-lang/pub/pull/1650

You can now split the git dependency into a url and path:

dependencies:
  protobuf:
    git:
      url: https://github.com/dart-lang/protobuf.git
      path: protobuf

Further reading: https://dart.dev/tools/pub/dependencies#git-packages

IcyIcicle
  • 564
  • 3
  • 15
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275
1

This is the answer I got from the dev team:

"This isn't something we're planning to support. Repos should have one-to-one correspondences with packages, and the packages should be located at the top level of the repos."

This makes it difficult to use dependencies to packages in a git repository as Eclipse always uses the project root as subfolder in the repository.

Gregor
  • 2,917
  • 5
  • 28
  • 50