Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/test_alt.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def test_auto_alt(runner, yadm_cmd, paths, autoalt):
os.system(" ".join(yadm_cmd("config", "yadm.auto-alt", autoalt)))

utils.create_alt_files(paths, "##default")
run = runner(yadm_cmd("status"))
run = runner(yadm_cmd("reset"))
assert run.success
assert run.err == ""
linked = utils.parse_alt_output(run.out)
Expand Down
19 changes: 9 additions & 10 deletions test/test_assert_private_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ def test_pdirs_missing(runner, yadm_cmd, paths, home):
if home:
env["HOME"] = paths.work

# run status
run = runner(command=yadm_cmd("status"), env=env)
# run reset
run = runner(command=yadm_cmd("reset"), env=env)
assert run.success
assert run.err == ""
assert "On branch master" in run.out

# confirm directories are created
# and are protected
Expand All @@ -48,7 +47,7 @@ def test_pdirs_missing(runner, yadm_cmd, paths, home):
# confirm directories are created before command is run:
if home:
assert re.search(
r"Creating.+\.(gnupg|ssh).+Creating.+\.(gnupg|ssh).+Running git command git status", run.out, re.DOTALL
r"Creating.+\.(gnupg|ssh).+Creating.+\.(gnupg|ssh).+Running git command git reset", run.out, re.DOTALL
), "directories created before command is run"


Expand All @@ -71,11 +70,11 @@ def test_pdirs_missing_apd_false(runner, yadm_cmd, paths):
# set configuration
os.system(" ".join(yadm_cmd("config", "--bool", "yadm.auto-private-dirs", "false")))

# run status
run = runner(command=yadm_cmd("status"))
# run reset
run = runner(command=yadm_cmd("reset"))
assert run.success
assert run.err == ""
assert "On branch master" in run.out
assert run.out == ""

# confirm directories are STILL missing
for pdir in PRIVATE_DIRS:
Expand All @@ -102,11 +101,11 @@ def test_pdirs_exist_apd_false(runner, yadm_cmd, paths):
# set configuration
os.system(" ".join(yadm_cmd("config", "--bool", "yadm.auto-perms", "false")))

# run status
run = runner(command=yadm_cmd("status"))
# run reset
run = runner(command=yadm_cmd("reset"))
assert run.success
assert run.err == ""
assert "On branch master" in run.out
assert run.out == ""

# created directories are STILL permissive
for pdir in PRIVATE_DIRS:
Expand Down
2 changes: 1 addition & 1 deletion test/test_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_perms(runner, yadm_cmd, paths, ds1, autoperms):

cmd = "perms"
if autoperms != "notest":
cmd = "status"
cmd = "reset"
run = runner(yadm_cmd(cmd), env={"HOME": paths.work})
assert run.success
assert run.err == ""
Expand Down
23 changes: 14 additions & 9 deletions yadm
Original file line number Diff line number Diff line change
Expand Up @@ -1143,18 +1143,23 @@ function git_command() {
fi

# ensure private .ssh and .gnupg directories exist first
# TODO: consider restricting this to only commands which modify the work-tree
declare -A non_modify
for nm_command in bisect blame bugreport cat-file check-attr check-ignore check-mailmap check-ref-format cherry column count-objects cvsexportcommit csvserver daemon describe diff-files diff-index diff difftool diff-tree fast-export fetch for-each-ref fsck get-tar-commit-id grep hash-object help http-backend http-fetch http-push imap-send instaweb log ls-files ls-remote ls-tree mailinfo name-rev push range-diff reflog remote request-pull rev-list rev-parse send-mail send-pack shortlog show-branch show-index show-ref show status var verify-commit verify-pack version whatchanged; do
non_modify["$nm_command"]=1
done

if [ "$YADM_WORK" = "$HOME" ]; then
auto_private_dirs=$(config --bool yadm.auto-private-dirs)
if [ "$auto_private_dirs" != "false" ]; then
for pdir in $(private_dirs all); do
assert_private_dirs "$pdir"
done
if [ -z "${non_modify["$1"]}" ]; then
if [ "$YADM_WORK" = "$HOME" ]; then
auto_private_dirs=$(config --bool yadm.auto-private-dirs)
if [ "$auto_private_dirs" != "false" ]; then
for pdir in $(private_dirs all); do
assert_private_dirs "$pdir"
done
fi
fi
fi

CHANGES_POSSIBLE=1
CHANGES_POSSIBLE=1
fi

# pass commands through to git
debug "Running git command $GIT_PROGRAM $*"
Expand Down