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

opam export: record git commit hash when a git url is specified #4055

Open
wants to merge 4 commits into
base: master
from

Conversation

@hannesm
Copy link
Member

hannesm commented Jan 7, 2020

this is useful for having an export file which can be imported and will contain the exact same sources (related to #4040), part of reproducibilty efforts

@rjbou

This comment has been minimized.

Copy link
Collaborator

rjbou commented Jan 10, 2020

Agree to integrate this sspecification, to be sure to rebuild the exact same switch. There is a side effect: I change pinned packages (and some from repo acceptiong allowing vcs urls): e;g if you pin a package to a branch, after an export & import this package will be pinned to an exact commit. There is a way to retrieve the commit branch (it's implemented in opam or a plugin), but we loose the information if first user wanted to pin to a commit or a branch.

let url' = OpamFile.URL.url url in
match url'.backend with
| `git ->
begin match OpamProcess.Job.run (OpamGit.VCS.revision (sd nv)) with

This comment has been minimized.

Copy link
@rjbou

rjbou Jan 10, 2020

Collaborator

You can use OpamRepository.revision, it already handles backend

@@ -477,43 +477,98 @@ let import_t ?ask importfile t =
end;
t

let read_overlays (read: package -> OpamFile.OPAM.t option) packages =
let read_overlays sd ~repos_roots (read: package -> OpamFile.OPAM.t option) packages =

This comment has been minimized.

Copy link
@rjbou

rjbou Jan 10, 2020

Collaborator

sd: a more complete name ? e.g. ~src_dir

let root = OpamStateConfig.(!r.root_dir) in
OpamSwitchState.with_ `Lock_none ~rt ~switch gt @@ fun st ->

This comment has been minimized.

Copy link
@rjbou

rjbou Jan 10, 2020

Collaborator

To retrieve just the path, you don't need to load the switch state. You can get their sources paths wtth OpamPath.Switch (cf. OpamSwitch.source_dir, you already have the pinned and installed selections).
Plus, If you need to load the switch, better do add it as export argument, and from that you can access to repo state & global state (but it is always better to take state as argument).
Plus there is a lock on the switch (file) below.

OpamSwitchCommand.export
OpamGlobalState.with_ `Lock_write @@ fun gt ->
OpamRepositoryState.with_ `Lock_none gt @@ fun rt ->
OpamSwitchCommand.export rt

This comment has been minimized.

Copy link
@rjbou

rjbou Jan 10, 2020

Collaborator

States need to be dropped after export call

@rjbou rjbou added the PR: WIP label Jan 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.