mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
nuxfs: Added support for git directive.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
37ae443e2c
commit
8aff47bd72
2 changed files with 18 additions and 4 deletions
20
bin/nuxfs
20
bin/nuxfs
|
|
@ -7,7 +7,7 @@ STARTDIR=$(pwd)
|
|||
nux.include nuxfs
|
||||
nux.include nuxfs.dsl
|
||||
|
||||
|
||||
GIT_BIN=$(which git)
|
||||
## verify - Verifies that directory matches nuxfs specification
|
||||
function task.verify {
|
||||
link.exists() {
|
||||
|
|
@ -26,6 +26,18 @@ function task.verify {
|
|||
nuxfs.warning "$1" "target '$NC_White$2$NC_No' does not exists."
|
||||
fi
|
||||
}
|
||||
git.exists() {
|
||||
nux.log debug "Testing '$1' as git repository"
|
||||
if test ! -e "$1/.git"; then
|
||||
nuxfs.error "$1" "is not git repository"
|
||||
return
|
||||
fi
|
||||
local remotes=$(grep "$2" "$1/.git/config" | wc -l)
|
||||
if [ $remotes -eq 0 ]; then
|
||||
nuxfs.error "$1" "Does not refer git remote '$2'"
|
||||
return;
|
||||
fi
|
||||
}
|
||||
def.notexists() {
|
||||
nuxfs.error "$1" "does not exists".
|
||||
}
|
||||
|
|
@ -46,7 +58,11 @@ function task.create {
|
|||
}
|
||||
|
||||
git.notexists() {
|
||||
log.warning "Not implemented";
|
||||
local cur_dir=$(nuxfs.dir.get);
|
||||
local rel_path=$(realpath -Lms $1 --relative-to $cur_dir)
|
||||
pushd $(nuxfs.dir.get) > /dev/null;
|
||||
$GIT_BIN clone "$2" $rel_path
|
||||
popd > /dev/null;
|
||||
}
|
||||
|
||||
nuxfs.dsl.execute .nuxfs
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
function nuxfs.relative {
|
||||
echo "$(nuxfs.dir.get)/$1"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue