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

[WIP] support dependencies as git url (including with exact commit hash) #1403

Closed
wants to merge 1 commit into from

Conversation

timotheecour
Copy link

@timotheecour timotheecour commented Mar 2, 2018

[reviewers: please ignore whitespace issues]

this supports for eg:

{
	"fileVersion": 1,
	"versions": {
		"ae": "@https://github.com/timotheecour/ae/commit/64430549f0bad65caa47cef523e69004a2d41b62"
	}
}

this fixes #51 (and is more general since allows that commit to come from a private fork)

also related to #632

it works but I have some question to improve it, please contact me on slack

@dlang-bot dlang-bot added the WIP label Mar 2, 2018
@dlang-bot
Copy link
Collaborator

Thanks for your pull request and interest in making D better, @timotheecour! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

@timotheecour
Copy link
Author

ping @s-ludwig @MartinNowak

@s-ludwig
Copy link
Member

s-ludwig commented Mar 5, 2018

My main concern is mixin the version string with the git repository. Isn't a git repository really more or less the same as a "path" attribute? The version should usually be inferred from the repository in this case (latest version tag, possibly with commit hash and number appended if more commits were made afterwards).

A case that I think should also be supported is specifying a URL that does not point to a specific commit, and then support version resolution by actually returning all version tags in the package provider.

Another consideration could be to support dropping the schema of the repository URL, so that the best available protocol could be used. But that would just be potentially nice to have.

@@ -34,6 +34,62 @@ struct PackageDependency {
Dependency spec;
}

struct GitDep{
Copy link
Member

Choose a reason for hiding this comment

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

Style: Should be fully spelled out (GitDependency) and before { there should always be a single space (or a line break in case of functions).

@s-ludwig
Copy link
Member

s-ludwig commented Mar 5, 2018

Actually, how about splitting this up into a "repository" part, specified as a separate parameter and without commit hash support, and support for "#2342d3f5a3246" style version strings to specify concrete commits (which may or may not work for other package providers).

Note: I used # here, because I felt that @ might still come in handy for other puposes later, without a concrete idea.

@wilzbach
Copy link
Member

BTW maybe similar to #1415, git+https:// might be used to avoid ambiguities if support for other versions systems is ever added (or maybe use fetching tar balls from somewhere)

@andre2007
Copy link
Contributor

As far as I know "git+https://..." is also the way you can specify dependencies in Node NPM.
As information URL has currently a small bug with multiple protocols.
I created an issue here #1418. The issue also contains a diff how a possible correction could look like.

Copy link
Member

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

Have a look at fetchzip.sh and test_registry.d for a way on how to add tests for this (or #1415's adaption of this).

+/
assert(spec[0]==Version.hashPrefix);
import std.regex;
auto m=spec[1..$].matchFirst(`^(.*?)/commit/([a-f0-9]+)$`.regex);
Copy link
Member

Choose a reason for hiding this comment

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

this will compile the regex on every execution. While std.regex now comes with a bit of caching, it's still better to do sth. like

static re = `...`.regex;
spec[1..$].matchFirst(re);

@@ -393,6 +459,7 @@ struct Dependency {
A specification is valid if it can match at least one version.
*/
bool valid() const {
if(isGit) return true;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this can be generalized to isHash?

URL url = gitDep.toURLZip;
logDiagnostic("Downloading from '%s'", url);
// TODO: foreach(i; 0..3)
download(url, path);
Copy link
Member

Choose a reason for hiding this comment

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

Might be worthwhile to generalize the retry logic in download (almost all supplier seem to require this)

@wilzbach wilzbach self-assigned this May 6, 2018
@andre2007
Copy link
Contributor

andre2007 commented Oct 27, 2018

I am not sure but I think the archive download only works for github and not for bitbucket.
E.g. this doesn't work:
https://bitbucket.org/cybershadow/d/archive/297be750e4725b6cdd4f72b0f2696bf011f34506.zip

I am sure Bitbucket supports s.th. similar but with another URL?
Maybe we should say, if you want to use git dependencies then there should be a git executable in
PATH.

@timotheecour any chance you could continue your work on this topic?

@timotheecour
Copy link
Author

timotheecour commented Oct 29, 2018

@andre2007

@timotheecour any chance you could continue your work on this topic?

I've moved on from D to Nim so I don't expect I'll have time to work on this; feel free to take over this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow dependency on specific ~master commit hash
5 participants