Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

`opam pin scan' #4285

Merged
merged 7 commits into from
Aug 26, 2020
Merged

`opam pin scan' #4285

merged 7 commits into from
Aug 26, 2020

Conversation

rjbou
Copy link
Collaborator

@rjbou rjbou commented Jul 27, 2020

opam pin scan url lists available package to pin in the given directory

$ opam pin scan git+https://github.com/ocaml/opam
# Name           # Version     # Url
opam-state       2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-solver      2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-repository  2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-installer   2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-format      2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-devel       2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-core        2.1.0~alpha2  git+https://github.com/ocaml/opam
opam-client      2.1.0~alpha2  git+https://github.com/ocaml/opam

Used with --normalise, displays a parseable output

$ opam pin scan git+https://github.com/ocaml/opam --normalise
opam-state.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-solver.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-repository.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-installer.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-format.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-devel.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-core.2.1.0~alpha2^git+https://github.com/ocaml/opam
opam-client.2.1.0~alpha2^git+https://github.com/ocaml/opam

This output is understandable by opam pin [add], e.g. to select only a subset of packages to pin

$ opam pin scan git+https://github.com/ocaml/opam --normalise | grep core | xargs ./opam pin add -n
[opam-core.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-core is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)

$ OPAMSTATUSLINE=never ./opam pin scan git+https://github.com/ocaml/opam --normalise  | xargs ./opam pin -y -n
This will pin the following packages: opam-state, opam-solver, opam-repository, opam-installer, opam-format, opam-devel, opam-core, opam-client. Continue? [Y/n] y
[opam-state.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-state is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-solver.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-solver is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-repository.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-repository is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-installer.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-installer is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-format.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-format is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-devel.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-devel is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-core.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-core is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)
[opam-client.2.1.0~alpha2] synchronised (git+https://github.com/ocaml/opam)
opam-client is now pinned to git+https://github.com/ocaml/opam (version 2.1.0~alpha2)

@avsm
Copy link
Member

avsm commented Jul 27, 2020

Great feature and very useful for CI (since it shows the versions inferred as well).

Is this opam-state.2.1.0~alpha2^git+https://github.com/ocaml/opam a new syntax in 2.1? I'm not familiar with the pkg^url format in 2.0

@rjbou
Copy link
Collaborator Author

rjbou commented Jul 27, 2020

It is a new syntax yes, introduced in this PR to be able to pipe opam pin scan output (as proposed in spec). It was hard to find a non-shell, non-package, non-version, non-url character :)
ftm, it is not planned to be included in 2.1.

@avsm
Copy link
Member

avsm commented Jul 27, 2020

Yeah, it is hard to find such a character; I'm going to use this syntax in opam-tools as well, since right now I use commas to separate the package name and the URL :)

Copy link
Member

@AltGr AltGr left a comment

Choose a reason for hiding this comment

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

Some nitpicking, but otherwise LGTM!

@rjbou
Copy link
Collaborator Author

rjbou commented Aug 24, 2020

Updated!

@rjbou rjbou added this to the 2.1.0~beta milestone Aug 26, 2020
@rjbou rjbou merged commit 466626d into ocaml:master Aug 26, 2020
@samoht
Copy link
Member

samoht commented Aug 26, 2020

We are using : in ocaml-ci-scripts instead of ^ (see https://github.com/ocaml/ocaml-ci-scripts/blob/master/README-travis.md#customizing-the-opam-pin-set) ; would be nice to normalise the conventions :-)

@rjbou
Copy link
Collaborator Author

rjbou commented Aug 26, 2020

: is not possible because it's an url character. But yes, it's a good idea o normalise.

@samoht
Copy link
Member

samoht commented Aug 27, 2020

yes but it should not appear in package name nor version, right? So you could split on the first left occurence.

@rjbou
Copy link
Collaborator Author

rjbou commented Aug 27, 2020

In this example it is not seen, but there is also the subpath as the fourth argument (cf. 2b3d347)

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

Successfully merging this pull request may close these issues.

4 participants