mirror of
https://github.com/jorgebucaran/fisher
synced 2024-10-05 09:32:37 +02:00
Remove git -C to improve support in exotic systems.
This commit is contained in:
parent
97b30dc97f
commit
a92a749e82
7 changed files with 50 additions and 28 deletions
|
@ -1,17 +1,15 @@
|
||||||
function __fisher_path_from_url -a url
|
function __fisher_path_from_url -a url
|
||||||
|
|
||||||
# What is the difference between path-from-url and url-from-path?
|
|
||||||
|
|
||||||
# Both functions use 'git ... --get-url'. The first one compares the given URL with
|
|
||||||
# the ls-remote of each repo in the cache and returns the path of the first match.
|
|
||||||
# The other one returns the ls-remote of the given path.
|
|
||||||
|
|
||||||
for file in $fisher_cache/*
|
for file in $fisher_cache/*
|
||||||
|
pushd $file
|
||||||
|
|
||||||
switch "$url"
|
switch "$url"
|
||||||
case (git -C $file ls-remote --get-url)
|
case (git ls-remote --get-url)
|
||||||
printf "%s\n" $file
|
printf "%s\n" $file
|
||||||
|
popd
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
popd
|
||||||
end
|
end
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -1,4 +1,8 @@
|
||||||
function __fisher_path_update -a path
|
function __fisher_path_update -a path
|
||||||
git -C $path checkout master --quiet ^ /dev/null
|
pushd $path
|
||||||
git -C $path pull --rebase origin master --quiet
|
|
||||||
|
git checkout master --quiet ^ /dev/null
|
||||||
|
git pull --rebase origin master --quiet
|
||||||
|
|
||||||
|
popd
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,11 @@ function __fisher_url_from_path -a path
|
||||||
if test -L "$path"
|
if test -L "$path"
|
||||||
readlink $path
|
readlink $path
|
||||||
else
|
else
|
||||||
set -l url (git -C "$path" ls-remote --get-url ^ /dev/null)
|
pushd $path
|
||||||
|
|
||||||
|
set -l url (git ls-remote --get-url ^ /dev/null)
|
||||||
|
|
||||||
|
popd
|
||||||
|
|
||||||
if test -z "$url"
|
if test -z "$url"
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
function -S git -a 1 file ctx action
|
function -S git
|
||||||
if test "$ctx" = "ls-remote" -a "$action" = --get-url
|
if contains -- ls-remote $argv
|
||||||
switch (basename "$file")
|
switch (basename (pwd))
|
||||||
case foo
|
case foo
|
||||||
echo https://github.com/foo/foo
|
echo https://github.com/foo/foo
|
||||||
case bar
|
case bar
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
set -l path $DIRNAME/.t-$TESTNAME-(random)
|
set -l path $DIRNAME/.t-$TESTNAME-(random)
|
||||||
|
|
||||||
# What is the difference between path-from-url and url-from-path?
|
|
||||||
# See __fisher_path_from_url.fish for the answer.
|
|
||||||
|
|
||||||
function -S setup
|
function -S setup
|
||||||
mkdir -p $path/cache/{foo,bar,baz}
|
mkdir -p $path/cache/{foo,bar,baz}
|
||||||
set -g fisher_cache $path/cache
|
set -g fisher_cache $path/cache
|
||||||
|
@ -19,14 +16,22 @@ end
|
||||||
|
|
||||||
for plugin in foo bar baz
|
for plugin in foo bar baz
|
||||||
test "$TESTNAME - Get cache path from url <$plugin> using Git"
|
test "$TESTNAME - Get cache path from url <$plugin> using Git"
|
||||||
$path/cache/$plugin = (__fisher_path_from_url https://github.com/$plugin/$plugin)
|
$path/cache/$plugin = (
|
||||||
|
__fisher_path_from_url https://github.com/$plugin/$plugin
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$TESTNAME - Fail if no url does not match any of the plugins ls-remote"
|
test "$TESTNAME - Fail if no url does not match any of the plugins ls-remote"
|
||||||
(__fisher_path_from_url https://github.com/norf/norf > /dev/null; printf $status) -eq 1
|
1 -eq (
|
||||||
|
__fisher_path_from_url https://github.com/norf/norf > /dev/null
|
||||||
|
printf $status
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$TESTNAME - Succeed if a url matches any the plugins ls-remote"
|
test "$TESTNAME - Succeed if a url matches any the plugins ls-remote"
|
||||||
(__fisher_path_from_url https://github.com/bar/bar > /dev/null; printf $status) -eq 0
|
0 -eq (
|
||||||
|
__fisher_path_from_url https://github.com/bar/bar > /dev/null
|
||||||
|
printf $status
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,18 +1,26 @@
|
||||||
|
set -g path $DIRNAME/.t-$TESTNAME-(random)
|
||||||
|
|
||||||
function -S setup
|
function -S setup
|
||||||
|
mkdir -p $path/foo
|
||||||
|
|
||||||
function git
|
function git
|
||||||
|
if test (pwd) = $path/foo
|
||||||
switch "$argv"
|
switch "$argv"
|
||||||
case "-C foo/bar checkout master --quiet"
|
case "checkout master --quiet"
|
||||||
printf checkout-
|
printf checkout-
|
||||||
case "-C foo/bar pull --rebase origin master --quiet"
|
|
||||||
|
case "pull --rebase origin master --quiet"
|
||||||
printf pull-rebase
|
printf pull-rebase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function -S teardown
|
function -S teardown
|
||||||
functions -e git
|
functions -e git
|
||||||
|
rm -rf $path
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$TESTNAME - Use Git to update given path"
|
test "$TESTNAME - Use Git to update given path"
|
||||||
"checkout-pull-rebase" = (__fisher_path_update foo/bar)
|
"checkout-pull-rebase" = (__fisher_path_update $path/foo)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
|
set -l path $DIRNAME/.t-$TESTNAME-(random)
|
||||||
set -l gist_plugin norf
|
set -l gist_plugin norf
|
||||||
|
|
||||||
function -S setup
|
function -S setup
|
||||||
|
mkdir -p $path/cache/{foo,bar,baz,$gist_plugin}
|
||||||
source $DIRNAME/helpers/git-ls-remote.fish
|
source $DIRNAME/helpers/git-ls-remote.fish
|
||||||
end
|
end
|
||||||
|
|
||||||
function -S teardown
|
function -S teardown
|
||||||
functions -e git
|
functions -e git
|
||||||
|
rm -rf $path
|
||||||
end
|
end
|
||||||
|
|
||||||
for plugin in foo bar baz
|
for plugin in foo bar baz
|
||||||
test "$TESTNAME - Get URL from repo's path in the cache ($plugin)"
|
test "$TESTNAME - Get URL from repo's path in the cache ($plugin)"
|
||||||
"https://github.com/$plugin/$plugin" = (
|
"https://github.com/$plugin/$plugin" = (
|
||||||
__fisher_url_from_path ...cache/$plugin
|
__fisher_url_from_path $path/cache/$plugin
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
test "$TESTNAME - Get <plugin>@<URL> for URLs of GitHub gists"
|
test "$TESTNAME - Get <plugin>@<URL> for URLs of GitHub gists"
|
||||||
"$gist_plugin@https://gist.github.com/$gist_plugin" = (
|
"$gist_plugin@https://gist.github.com/$gist_plugin" = (
|
||||||
__fisher_url_from_path ...cache/$gist_plugin
|
__fisher_url_from_path $path/cache/$gist_plugin
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue