Skip to content
Open
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
5 changes: 4 additions & 1 deletion .github/scripts/main/opam-rt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export PATH=~/local/bin:$PATH
export OPAMKEEPLOGS=1

# TODO: Make opam-rt compatible with non-master initial branches
git config --global init.defaultBranch master
sudo git config --system init.defaultBranch master
# TODO: Make opam-rt compatible with a hermetic git configuration
sudo git config --system user.name 'OPAM test environment'
sudo git config --system user.email '[email protected]'

cd $CACHE/opam-rt
make KINDS="local git" run
8 changes: 3 additions & 5 deletions .github/scripts/main/preamble.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
CWD=$PWD
if [ "$RUNNER_OS" = Windows ]; then
CACHE="$(cygpath 'D:\Cache')"
SUDO=''
else
CACHE=~/.cache
CACHE=$(eval echo $CACHE)
SUDO=sudo
fi
echo "Cache -> $CACHE"
OCAML_LOCAL=$CACHE/ocaml-local
Expand All @@ -31,11 +33,7 @@ OPAMBSSWITCH=opam-build

export OPAMCONFIRMLEVEL=unsafe-yes

git config --global user.email "[email protected]"
git config --global user.name "Github Actions CI"
git config --global gc.autoDetach false
git config --global init.defaultBranch thisShouldNotHappen
git config --global protocol.file.allow always
$SUDO git config --system gc.autoDetach false

if [ -d ~/opam-repository ]; then
OPAM_REPO_CACHE=file://$HOME/opam-repository
Expand Down
2 changes: 1 addition & 1 deletion src/repository/opamGit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module VCS : OpamVCS.VCS = struct
let init repo_root repo_url =
OpamFilename.mkdir repo_root;
OpamProcess.Job.of_list [
git repo_root [ "init" ];
git repo_root [ "-c"; "init.defaultBranch=main"; "init" ];
(* Enforce this option, it can break our use of git if set *)
git repo_root [ "config" ; "--local" ; "fetch.prune"; "false"];
(* We reset diff.noprefix to ensure we get a `-p1` patch and avoid <https://github.com/ocaml/opam/issues/3627>. *)
Expand Down
8 changes: 7 additions & 1 deletion src/state/opamFileTools.ml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,13 @@ let template nv =
| _ -> [email]
with Not_found -> match email with
| Some e -> [e]
| None -> []
| None ->
if Sys.win32 then
match Sys.getenv_opt "USERNAME", Sys.getenv_opt "USERDOMAIN" with
| Some name, Some domain -> [name ^ "@" ^ domain]
| _ -> []
else
[]
in
create nv
|> with_name_opt None
Expand Down
22 changes: 13 additions & 9 deletions tests/lib/patchDiff.ml
Original file line number Diff line number Diff line change
Expand Up @@ -298,19 +298,23 @@ let git_cmds repo_root commands error_msg =
("-C"::(OpamFilename.Dir.to_string repo_root)::args))
commands
in
try
List.iter (fun command ->
match OpamProcess.run command with
| {OpamProcess.r_code = 0; _ } -> ()
| _ -> failwith (OpamProcess.string_of_command command))
commands
with Failure e ->
print "ERROR:%s: %s\n" error_msg (rm_hex e)
List.exists (fun command ->
match OpamProcess.run command with
| {OpamProcess.r_code = 0; _ } -> false
| {OpamProcess.r_stderr; _ } ->
let cmd = rm_hex (OpamProcess.string_of_command command) in
print "ERROR:%s: %s\n" error_msg cmd;
List.iter print_endline r_stderr;
true)
commands
|> ignore

let make_git_repo dir =
let first_root = dir / first in
let commands = [
[ "init"];
[ "init" ];
[ "config"; "user.name"; "OPAM test environment" ];
[ "config"; "user.email"; "[email protected]" ];
[ "add"; "--all" ];
[ "commit"; "-qm"; "first" ];
] in
Expand Down
72 changes: 37 additions & 35 deletions tests/reftests/action-disk.test

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions tests/reftests/assume-built.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ build: [[ "test" "-f" "ongoing.txt" ] [ "sh" "-c" "cat ongoing.txt > out" ]]
install: [ ["test" "-f" "out" ] ["touch" "installed"] ]
### <ongoing/ongoing.txt>
versionned
### git -C ./ongoing init -q --initial-branch=master
### git -C ./ongoing init -q --initial-branch=main
### git -C ./ongoing config core.autocrlf false
### git -C ./ongoing config user.name 'OPAM test environment'
### git -C ./ongoing config user.email '[email protected]'
### git -C ./ongoing add -A
### git -C ./ongoing commit -qm "inplace test"
### <ongoing/newfile.txt>
new!
### opam switch create assume-built --empty
### opam pin ./ongoing -n
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev)
ongoing is now pinned to git+file://${BASEDIR}/ongoing#main (version dev)
### : assume built
### opam install ongoing -v | sed-cmd test sh touch

Expand Down Expand Up @@ -151,8 +153,8 @@ Done.

<><> Synchronising pinned packages ><><><><><><><><><><><><><><><><><><><><><><>
Processing 1/1: [ongoing.dev: git]
[ongoing.dev] synchronised (git+file://${BASEDIR}/ongoing#master)
[ongoing] Installing new package description from upstream git+file://${BASEDIR}/ongoing#master
[ongoing.dev] synchronised (git+file://${BASEDIR}/ongoing#main)
[ongoing] Installing new package description from upstream git+file://${BASEDIR}/ongoing#main

The following actions will be performed:
=== install 1 package
Expand All @@ -168,7 +170,7 @@ Done.
### test -f ./ongoing/installed
### : assume built & opam file variables :
### opam unpin ongoing
Ok, ongoing is no longer pinned to git+file://${BASEDIR}/ongoing#master (version dev)
Ok, ongoing is no longer pinned to git+file://${BASEDIR}/ongoing#main (version dev)
The following actions will be performed:
=== remove 1 package
- remove ongoing dev
Expand Down Expand Up @@ -200,7 +202,7 @@ install: [
### git -C ongoing clean -fdqx
### opam pin ./ongoing -n
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version 1.0)
ongoing is now pinned to git+file://${BASEDIR}/ongoing#main (version 1.0)
### touch ongoing/out
### opam install qux
The following actions will be performed:
Expand Down Expand Up @@ -228,7 +230,7 @@ Done.
### : assume built & undefined opam file variables :
### OPAMSTRICT=0
### opam unpin ongoing
Ok, ongoing is no longer pinned to git+file://${BASEDIR}/ongoing#master (version 1.0)
Ok, ongoing is no longer pinned to git+file://${BASEDIR}/ongoing#main (version 1.0)
The following actions will be performed:
=== remove 1 package
- remove ongoing 1.0
Expand All @@ -254,7 +256,7 @@ install: [
### git -C ongoing clean -fdqx
### opam pin ./ongoing -n
[NOTE] Package ongoing does not exist in opam repositories registered in the current switch.
ongoing is now pinned to git+file://${BASEDIR}/ongoing#master (version dev)
ongoing is now pinned to git+file://${BASEDIR}/ongoing#main (version dev)
### touch ongoing/out
### opam install ongoing --assume-built --with-test

Expand Down
8 changes: 5 additions & 3 deletions tests/reftests/download.test
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ Done.
opam-version: "2.0"
### <bar/a-file>
content
### git -C bar init -q --initial-branch=master
### git -C bar init -q --initial-branch=main
### git -C bar config core.autocrlf false
### git -C bar config user.name 'OPAM test environment'
### git -C bar config user.email '[email protected]'
### git -C bar add opam a-file
### git -C bar commit -qm "init"
### <pkg:bar.1>
Expand Down Expand Up @@ -236,7 +238,7 @@ The following actions will be performed:
SYSTEM mkdir ${OPAMTMP}
SYSTEM mkdir ${BASEDIR}/OPAM/download/.opam-switch/sources/bar.1
Processing 1/1: [bar.1: git]
+ git "init" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/bar.1)
+ git "-c" "init.defaultBranch=main" "init" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/bar.1)
+ git "config" "--local" "fetch.prune" "false" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/bar.1)
+ git "config" "--local" "diff.noprefix" "false" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/bar.1)
+ git "config" "--local" "core.autocrlf" "false" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/bar.1)
Expand Down Expand Up @@ -295,7 +297,7 @@ The following actions will be performed:
SYSTEM mkdir ${OPAMTMP}
SYSTEM mkdir ${BASEDIR}/OPAM/download/.opam-switch/sources/qux.1
Processing 1/1: [qux.1: git]
+ git "init" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/qux.1)
+ git "-c" "init.defaultBranch=main" "init" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/qux.1)
+ git "config" "--local" "fetch.prune" "false" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/qux.1)
+ git "config" "--local" "diff.noprefix" "false" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/qux.1)
+ git "config" "--local" "core.autocrlf" "false" (CWD=${BASEDIR}/OPAM/download/.opam-switch/sources/qux.1)
Expand Down
Loading
Loading