-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #185. Try was making way too many tempfiles. Now we store everything in the sandbox, with a tiny bit of nuance: $IGNORE_FILE needs to be created in advance to handle the args properly. So we create that temporary unconditionally. When running a command (the try() function), we'll move $IGNORE_FILE into the sandbox. When running try commit or try summary, we just delete $IGNORE_FILE at the end.
- Loading branch information
Showing
2 changed files
with
58 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/sh | ||
# shellcheck disable=SC2010,SC2126,SC2181 | ||
|
||
TRY_TOP="${TRY_TOP:-$(git rev-parse --show-toplevel --show-superproject-working-tree 2>/dev/null || echo "${0%/*}")}" | ||
TRY="$TRY_TOP/try" | ||
|
||
workdir="$(mktemp -d)" | ||
cd "$workdir" || exit 1 | ||
|
||
initial_count="$(ls "${TMPDIR-/tmp}" | grep -e "^.*\.try-[0-9]*$" | wc -l)" | ||
|
||
sandbox=$($TRY -n "touch $HOME/foo") | ||
[ $? -eq 0 ] || exit 2 | ||
|
||
post_count="$(ls "${TMPDIR-/tmp}" | grep -e "^.*\.try-[0-9]*$" | wc -l)" | ||
|
||
# just one new tempfile | ||
[ "$((initial_count + 1))" -eq "$post_count" ] || exit 3 | ||
[ -f "$sandbox/upperdir$HOME/foo" ] || exit 4 | ||
|
||
# deliberately not the pattern of try sandboxes | ||
sandbox=local | ||
mkdir "$sandbox" || exit 5 | ||
$TRY -D "$sandbox" "touch $HOME/bar" || exit 6 | ||
|
||
final_count="$(ls "${TMPDIR-/tmp}" | grep -e "^.*\.try-[0-9]*$" | wc -l)" | ||
|
||
# no new tempfiles! | ||
[ "$post_count" -eq "$final_count" ] || exit 7 | ||
[ -f "$sandbox/upperdir$HOME/bar" ] || exit 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters