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

Feature request: "revision" field in rockspecs #569

Open
Alloyed opened this issue Jun 8, 2016 · 11 comments · May be fixed by #623
Open

Feature request: "revision" field in rockspecs #569

Alloyed opened this issue Jun 8, 2016 · 11 comments · May be fixed by #623

Comments

@Alloyed
Copy link
Contributor

Alloyed commented Jun 8, 2016

example:

source = {
  url = "git://my/repo",
  revision = "86d59e66d0c12656ed34d4f4a9bab06ac7775f77"
}

In this context revision means an atomic reference to a repo's state, e.g. commit hashes in git and changeset IDs in Mercurial.

This can be useful for when you don't directly control a source repo to add tags to it, or if you want more specific rockspecs than you want tags. It can also be used as verification for tags, the same way source.md5 is used.

Implementation-wise, it doesn't look like git lets you clone a specific commit, so instead you need to pick the closest branch/tag and then git checkout from there. Mercurial's --rev flag also does changesets in addition to branches/tags so there it's just a matter of also passing the changeset id in.

@mpeterv
Copy link
Contributor

mpeterv commented Jun 17, 2016

Looks like a good idea, but probably can be "fixed" only in LR 3 for compatibility reasons.

Implementation-wise, it doesn't look like git lets you clone a specific commit, so instead you need to pick the closest branch/tag and then git checkout from there.

How would you pick the branch? I think this requires cloning full repo and then checking out the revision directly.

@mpeterv mpeterv added this to the LuaRocks 3 milestone Jun 17, 2016
@daurnimator
Copy link
Member

I swear I've requested before somewhere but I can't find a link.

FWIW some git programs use the fragment to indicate it.
i.e. url = "git://my/repo#86d59e66d0c12656ed34d4f4a9bab06ac7775f77"

@mpeterv
Copy link
Contributor

mpeterv commented Jun 17, 2016

FWIW some git programs use the fragment to indicate it.
i.e. url = "git://my/repo#86d59e66d0c12656ed34d4f4a9bab06ac7775f77"

This doesn't appear to work with the regular command line git which luarocks uses. (at least with my git 2.7.4)

@mpeterv
Copy link
Contributor

mpeterv commented Jun 17, 2016

Luarocks could split out the revision itself, of course.

@daurnimator
Copy link
Member

This doesn't appear to work with the regular command line git which luarocks uses. (at least with my git 2.7.4)

Correct. it's not used by the git command line tool AFAIK, but it is used by other systems.
e.g. the docker build command
This form usually allows any git 'ref-spec', so can be used for branches too.

Which brings me to an alternate idea: we already have a branch field: why not just allow commit hashes in there too? (that works with some git sub commands but not others)

@mpeterv
Copy link
Contributor

mpeterv commented Jun 17, 2016

Which brings me to an alternate idea: we already have a branch field: why not just allow commit hashes in there too? (that works with some git sub commands but not others)

It doesn't work with clone, and it's impossible to know whether it's a branch or a commit hash beforehand if it only consists of hexadecimal characters.

@daurnimator
Copy link
Member

It doesn't work with clone, and it's impossible to know whether it's a branch or a commit hash beforehand if it only consists of hexadecimal characters.

We can pass it straight to e.g. git checkout.

@mpeterv
Copy link
Contributor

mpeterv commented Jun 17, 2016

But then we have to always clone full repo.

@daurnimator
Copy link
Member

I wonder how e.g. npm handle this? (they use the same fragment thing)

@Alloyed
Copy link
Contributor Author

Alloyed commented Jun 17, 2016

here's the relevant part of the npm source afaict
https://github.com/npm/npm/blob/6823807bba6c00228a724e1205ae90d67df0adad/lib/cache/add-remote-git.js#L242

It looks like they do a full clone into a cache, and then every time they need a version of that package they clone->checkout from it.

@mpeterv
Copy link
Contributor

mpeterv commented Jun 17, 2016

And in hererocks I do full clone if the ref is hexadecimal and pass it to --branch otherwise. But for LuaRocks I don't think there is need to overload source.branch or source.tag because it's not a command-line argument, adding a new source.revision field looks better to me.

@Alloyed Alloyed linked a pull request Oct 6, 2016 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants