mirror of
https://github.com/nmattia/niv.git
synced 2024-09-19 11:27:40 +03:00
Actually update git specs
This commit is contained in:
parent
4fbbbf28d4
commit
3377472122
@ -295,9 +295,14 @@ cmdUpdate = \case
|
||||
|
||||
eFinalSpec <- case HMS.lookup packageName sources of
|
||||
Just defaultSpec -> do
|
||||
-- lookup the "type" to find a Cmd to run, defaulting to legacy
|
||||
-- github
|
||||
let cmd = case HMS.lookup "type" (unPackageSpec defaultSpec) of
|
||||
Just "git" -> gitCmd
|
||||
_ -> githubCmd
|
||||
fmap attrsToSpec <$> tryEvalUpdate
|
||||
(specToLockedAttrs cliSpec <> specToFreeAttrs defaultSpec)
|
||||
(updateCmd githubCmd)
|
||||
(updateCmd cmd)
|
||||
|
||||
Nothing -> abortCannotUpdateNoSuchPackage packageName
|
||||
|
||||
@ -314,9 +319,14 @@ cmdUpdate = \case
|
||||
\packageName defaultSpec -> do
|
||||
tsay $ "Package: " <> unPackageName packageName
|
||||
let initialSpec = specToFreeAttrs defaultSpec
|
||||
-- lookup the "type" to find a Cmd to run, defaulting to legacy
|
||||
-- github
|
||||
let cmd = case HMS.lookup "type" (unPackageSpec defaultSpec) of
|
||||
Just "git" -> gitCmd
|
||||
_ -> githubCmd
|
||||
finalSpec <- fmap attrsToSpec <$> tryEvalUpdate
|
||||
initialSpec
|
||||
(updateCmd githubCmd)
|
||||
(updateCmd cmd)
|
||||
pure finalSpec
|
||||
|
||||
let (failed, sources') = partitionEithersHMS esources'
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
# TODO: this doesn' test anything meaningful yet because "niv git PACKAGE"
|
||||
# doesn't parse yet
|
||||
pkgs.runCommand "foo"
|
||||
pkgs.runCommand "git-test"
|
||||
{ nativeBuildInputs = [ pkgs.git niv pkgs.nix pkgs.jq ]; }
|
||||
(
|
||||
# First we create a dummy git repo with a single commit
|
||||
# First we create a dummy git repo with one commit on master, and one commit
|
||||
# on "branch".
|
||||
''
|
||||
gitdir=$(mktemp -d)
|
||||
pushd $gitdir > /dev/null
|
||||
@ -16,6 +17,15 @@ pkgs.runCommand "foo"
|
||||
git add file
|
||||
git commit -m "Initial commit"
|
||||
gitrev=$(git rev-parse HEAD)
|
||||
|
||||
git checkout -b branch
|
||||
echo world >> file
|
||||
git add file
|
||||
git commit -m "second commit"
|
||||
gitrev2=$(git rev-parse HEAD)
|
||||
|
||||
# reset to master as "default branch"
|
||||
git checkout master
|
||||
popd > /dev/null
|
||||
'' +
|
||||
|
||||
@ -47,6 +57,14 @@ pkgs.runCommand "foo"
|
||||
echo "Mismatched revCount: 1 != $nivnixrevcount"
|
||||
exit 42
|
||||
fi
|
||||
|
||||
niv update my-git-repo -a ref=branch
|
||||
nivrev2=$(nix eval --json '(import ./nix/sources.nix).my-git-repo.rev' | jq -r)
|
||||
if [ ! "$gitrev2" = "$nivrev2" ]; then
|
||||
echo "Mismatched revs: $gitrev2 != $nivrev2"
|
||||
exit 42
|
||||
fi
|
||||
|
||||
popd > /dev/null
|
||||
|
||||
touch $out
|
||||
|
Loading…
Reference in New Issue
Block a user