Created
July 13, 2022 15:00
-
-
Save okurz/49b7ca78611350b6293fc2a79e1f8345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# succeeds as expected, shows hash | |
sudo -u _openqa-worker perl -wE ' | |
my $dirname = "/var/lib/openqa/share/tests/opensuse"; | |
my $checksafe = q{git config --global --get safe.directory | grep -q}; | |
my $addsafe = q{HOME=$(mktemp -d --tmpdir os-autoinst-git.XXXXX) && git config --global --add safe.directory}; | |
my $version = qx{($checksafe "$dirname" && git -C "$dirname" rev-parse HEAD || $addsafe "$dirname" && git -C "$dirname" rev-parse HEAD && echo rm -r \$HOME)}; | |
$version ||= "(unreadable git hash)"; | |
chomp($version); | |
say "HASH: $version"' | |
# fails as expected, shows git error about unsafe repository | |
sudo -u _openqa-worker perl -wE ' | |
my $dirname = "/var/lib/openqa/share/tests/opensuse"; | |
my $version = qx{git -C "$dirname" rev-parse HEAD}; | |
$version ||= "(unreadable git hash)"; | |
chomp($version); | |
say "HASH: $version"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment