1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00
nux-env/inc/dsl/nuxfs.check.dsl
Tony Tkacik 91cb61527f nuxfs: Added docs & shorthands for error testing.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
2017-06-11 17:23:12 +02:00

38 lines
1 KiB
Text

.use-dsl nuxfs
link.entered() {
nux.log debug "Testing '$abs_path' as link"
if test ! -h "$abs_path"; then
.error "is not symlink."
return
fi
local REAL_LINK=$(readlink "$abs_path")
nux.log trace "Target is: $target, real link: $REAL_LINK"
if test ! "$REAL_LINK" = "$target"; then
MAT_REAL=$(realpath "$REAL_LINK")
local cdir=$(dirname "$abs_path")
MAT_TARGET=$(realpath "$cdir/$target")
if test "$MAT_REAL" = "$MAT_TARGET"; then
.warning "is using different definition for target '$3'"
else
.error "links to $REAL_LINK instead of $target"
return
fi
fi
if test ! -e "$abs_path"; then
.warning "target '$NC_White$target$NC_No' does not exists."
fi
}
git.entered() {
nux.log debug "Testing '$rel_path' as git repository"
if test ! -e "$rel_path/.git"; then
.error "$rel_path" "is not git repository"
return
fi
local remotes=$(grep "$origin" "$rel_path/.git/config" | wc -l)
if [ $remotes -eq 0 ]; then
.error "$rel_path" "Does not refer git remote '$origin'"
return;
fi
}