added check-tree command
This commit is contained in:
parent
68683c9c97
commit
af3784ba24
36
rtenets
36
rtenets
|
@ -282,6 +282,41 @@ create_tenet_file_tree() {
|
|||
script_stub make_all_figures "Generating figures..."
|
||||
}
|
||||
|
||||
# Check tree structure
|
||||
check-tree() {
|
||||
local directory="$1"
|
||||
local check_failed=0
|
||||
pushd "${directory}" >/dev/null
|
||||
|
||||
# Test directory is a git repo
|
||||
if ! \git status > /dev/null 2>&1; then
|
||||
warning "git failed: $PWD is not a repo"
|
||||
check_failed=1
|
||||
fi
|
||||
|
||||
# Test config values
|
||||
if ! ( [[ "$(\git config user.name)" != "" ]] \
|
||||
&& [[ "$(\git config user.email)" != "" ]] ); then
|
||||
warning "git config failed"
|
||||
check_failed=1
|
||||
fi
|
||||
|
||||
# Test file structure
|
||||
mandatory_files=("README.md~"
|
||||
"AUTHORS"
|
||||
"COPYING"
|
||||
"make_all_figures"
|
||||
"tests/run_all_tests")
|
||||
for file in ${mandatory_files[*]}; do
|
||||
if ! [[ -f "${file}" ]]; then
|
||||
warning "file ${file} is missig"
|
||||
check_failed=1
|
||||
fi
|
||||
done
|
||||
popd >/dev/null
|
||||
return ${check_failed}
|
||||
}
|
||||
|
||||
# ----------------- Gitea commands -----------------------
|
||||
|
||||
get_gitea_owner() {
|
||||
|
@ -440,6 +475,7 @@ main() {
|
|||
[init-gitea]=init-gitea
|
||||
[init-workflow]=init-workflow
|
||||
[create]=create
|
||||
[check-tree]=check-tree
|
||||
)
|
||||
|
||||
"${COMMANDS[${command:-default}]:-${COMMANDS[default]}}" "${other_args}"
|
||||
|
|
|
@ -6,26 +6,9 @@ source ../rtenets
|
|||
test_init-tree() {
|
||||
info "running test_init-tree"
|
||||
init-tree .
|
||||
|
||||
# Test directory is a git repo
|
||||
\git status > /dev/null 2>&1 \
|
||||
|| ( echo "git failed: $PWD is not a repo"; exit 1 )
|
||||
|
||||
# Test config values
|
||||
[[ "$(\git config user.name)" != "" ]] \
|
||||
&& [[ "$(\git config user.email)" != "" ]] \
|
||||
|| ( echo "git config failed"; exit 1 )
|
||||
|
||||
# Test file structure
|
||||
mandatory_files=("README.md~"
|
||||
"AUTHORS"
|
||||
"COPYING"
|
||||
"make_all_figures"
|
||||
"tests/run_all_tests")
|
||||
for file in ${mandatory_files[*]}; do
|
||||
[[ -f "${file}" ]] || ( echo "file ${file} is missig"; exit 1 )
|
||||
done
|
||||
info "finished test_init-tree"
|
||||
check-tree . \
|
||||
&& info "[✅] passed test_init-tree" \
|
||||
|| warning "[❌] failed test_init-tree"
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue