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

Make it so pin list display the current revision of the pinned repo #6274

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/scripts/main/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ if [ "$OPAM_TEST" = "1" ]; then
fi
cd $CACHE/opam-rt
git fetch origin
if [ "$GITHUB_EVENT_NAME" = "pull_request" ] && git ls-remote --exit-code origin "$GITHUB_PR_USER/$BRANCH" ; then
BRANCH=$GITHUB_PR_USER/$BRANCH
fi
if git ls-remote --exit-code origin $BRANCH ; then
if git branch | grep -q $BRANCH; then
git checkout $BRANCH
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ci.ml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ let main_test_job ~analyse_job ~build_linux_job ~build_windows_job:_ ~build_macO
let matrix = platform_ocaml_matrix ~fail_fast:false start_latests_ocaml in
let host = host_of_platform platform in
let ocamlv = "${{ matrix.ocamlv }}" in
job ~oc ~workflow ?section ~runs_on:(Runner [runner]) ~env:[("OPAM_TEST", "1")] ~matrix ~needs ("Test-" ^ name_of_platform platform)
job ~oc ~workflow ?section ~runs_on:(Runner [runner])
~env:[("OPAM_TEST", "1"); ("GITHUB_PR_USER", "${{ github.event.pull_request.user.login }}")]
~matrix ~needs ("Test-" ^ name_of_platform platform)
++ only_on MacOS (install_sys_packages ["coreutils"; "gpatch"] ~descr:"Install gnu coreutils" [MacOS])
++ checkout ()
++ only_on Linux (run "Install bubblewrap" ["sudo apt install bubblewrap"])
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ jobs:
fail-fast: false
env:
OPAM_TEST: 1
GITHUB_PR_USER: ${{ github.event.pull_request.user.login }}
steps:
- name: Checkout tree
uses: actions/checkout@v4
Expand Down Expand Up @@ -336,6 +337,7 @@ jobs:
fail-fast: false
env:
OPAM_TEST: 1
GITHUB_PR_USER: ${{ github.event.pull_request.user.login }}
steps:
- name: Install gnu coreutils
run: brew install coreutils gpatch
Expand Down
2 changes: 2 additions & 0 deletions master_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ users)
## Config

## Pin
* [NEW] Make it so pin list display the current revision of a pinned repository in a new column [#6274 @desumn - fix #5533]

## List

Expand Down Expand Up @@ -136,6 +137,7 @@ users)
## Github Actions
* Add a doc generation job under linux [#5349 @rjbou]
* Update the github action scripts now that homebrew renamed the GNU patch binary to gpatch [#6296 @kit-ty-kate]
* Add branch scheme `username/branch` for opam-rt specific branch to use [#6274 @rjbou]

## Doc
* Update the command to install opam to point to the new simplified url on opam.ocaml.org [#6226 @kit-ty-kate]
Expand Down
5 changes: 4 additions & 1 deletion src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3199,7 +3199,10 @@ let pin_doc = "Pin a given package to a specific version or source."
let pin ?(unpin_only=false) cli =
let doc = pin_doc in
let commands = [
cli_original, "list", `list, [], "Lists pinned packages.";
cli_original, "list", `list, [],
"Lists pinned packages. \
If the source is a remote repository, \
displays the hash representing its state.";
cli_from cli2_1, "scan", `scan, ["DIR"],
"Lists available packages to pin in directory.";
cli_original, "add", `add, ["PACKAGE"; "TARGET"],
Expand Down
17 changes: 16 additions & 1 deletion src/client/opamPinCommand.ml
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,25 @@ let list st ~short =
(OpamPackage.version_to_string inst))]
with Not_found -> OpamConsole.colorise `yellow "(uninstalled)", []
in
let vcs_revision =
let open OpamStd.Option.Op in
url >>| OpamFile.URL.url >>= fun url ->
match url.OpamUrl.backend with
| #OpamUrl.version_control ->
let srcdir = OpamSwitchState.source_dir st nv in
let color, rev =
match OpamProcess.Job.run (OpamRepository.revision srcdir url) with
| None -> (`red, "error while fetching current revision")
| Some ver -> (`magenta, OpamPackage.Version.to_string ver)
in
Some (Printf.sprintf "(at %s)" (OpamConsole.colorise color (rev)))
| _ -> None
in
[ OpamPackage.to_string nv;
state;
OpamConsole.colorise `blue kind;
String.concat " " (target::extra) ]
String.concat " " (target::extra);
OpamStd.Option.default "" vcs_revision ]
with Not_found ->
[ OpamPackage.to_string nv;
OpamConsole.colorise `red " (no definition found)" ]
Expand Down
26 changes: 13 additions & 13 deletions tests/reftests/pin.test
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ The following actions will be performed:
-> installed no-url.ved
Done.
### : list
### opam pin list
nip-git.ved git git+file://${BASEDIR}/nip-git#master
nip-git2.ved git git+file://${BASEDIR}/nip-git2#master
### opam pin list | ' \(at [0-9a-f]+\)$' -> ' (at HASH)'
nip-git.ved git git+file://${BASEDIR}/nip-git#master (at HASH)
nip-git2.ved git git+file://${BASEDIR}/nip-git2#master (at HASH)
nip-path.ved rsync file://${BASEDIR}/nip-path
nip-path2.ved rsync file://${BASEDIR}/nip-path2
nip-path3.ved rsync file://${BASEDIR}/nip-path3
Expand Down Expand Up @@ -332,11 +332,11 @@ The following actions will be performed:
[NOTE] Pinning command successful, but your installed packages may be out of sync.
# Return code 31 #
### : list
### opam pin list
### opam pin list | ' \(at [0-9a-f]+\)$' -> ' (at HASH)'
nip.1 version 1
nip-git.ved rsync file://${BASEDIR}/nip-git
nip-git2.ved git git+file://${BASEDIR}/nip-git2#master
nip-git3.ved git git+file://${BASEDIR}/nip-git3#master
nip-git2.ved git git+file://${BASEDIR}/nip-git2#master (at HASH)
nip-git3.ved git git+file://${BASEDIR}/nip-git3#master (at HASH)
nip-path.ved rsync file://${BASEDIR}/nip-path
nip-path3.ved rsync file://${BASEDIR}/nip-path3
no-url.1 (uninstalled) local definition
Expand Down Expand Up @@ -407,8 +407,8 @@ The following actions will be performed:
-> installed nip-path2.ved
Done.
### : list
### opam pin list
nip-git.ved git git+file://${BASEDIR}/nip-git#master
### opam pin list | ' \(at [0-9a-f]+\)$' -> ' (at HASH)'
nip-git.ved git git+file://${BASEDIR}/nip-git#master (at HASH)
nip-git2.ved rsync file://${BASEDIR}/nip-git2
nip-path.ved rsync file://${BASEDIR}/nip-path
nip-path2.ved rsync file://${BASEDIR}/nip-path2
Expand Down Expand Up @@ -452,8 +452,8 @@ Done.
# Name # Installed # Synopsis
nip-path ved pinned to version ved at file://${BASEDIR}/nip-path
nip-path2 ved pinned to version ved at file://${BASEDIR}/nip-path2
### opam pin list
nip-git4.ved (uninstalled) git git+file://${BASEDIR}/nip-git4#master
### opam pin list | ' \(at [0-9a-f]+\)$' -> ' (at HASH)'
nip-git4.ved (uninstalled) git git+file://${BASEDIR}/nip-git4#master (at HASH)
nip-path.ved rsync file://${BASEDIR}/nip-path
nip-path2.ved rsync file://${BASEDIR}/nip-path2
### find OPAM/actions/lib -name '*.t' | sort
Expand Down Expand Up @@ -570,11 +570,11 @@ The following actions will be performed:
### :::::::::::::::::::::::
### opam switch kinds
### : pin list
### opam pin list
### opam pin list | ' \(at [0-9a-f]+\)$' -> ' (at HASH)'
nip.1 version 1
nip-git.ved rsync file://${BASEDIR}/nip-git
nip-git2.ved git git+file://${BASEDIR}/nip-git2#master
nip-git3.ved git git+file://${BASEDIR}/nip-git3#master
nip-git2.ved git git+file://${BASEDIR}/nip-git2#master (at HASH)
nip-git3.ved git git+file://${BASEDIR}/nip-git3#master (at HASH)
nip-path.ved rsync file://${BASEDIR}/nip-path
nip-path3.ved rsync file://${BASEDIR}/nip-path3
no-url.1 (uninstalled) local definition
Expand Down
Loading