-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a "clone" command for git clone'ing repos
libgit sucks hard, so let's just fork and call 'git clone', using sd_event to make things nice and async. In the case where the git repository already exists, let's transparently turn "git clone" into "git pull", in order to make updates simpler. There's probably bugs here. I need better (any) unit tests for the event loop portion of this...
- Loading branch information
1 parent
1fb0d47
commit c73bbee
Showing
13 changed files
with
339 additions
and
36 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,19 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC1090 | ||
source "${0%/*}/common" | ||
|
||
# should clone | ||
if ! auracle clone auracle-git; then | ||
echo "FAIL: expected 0 exit status, got non-zero" >&2 | ||
exit 1 | ||
fi | ||
|
||
# should do nothing (update) | ||
if ! auracle clone auracle-git; then | ||
echo "FAIL: expected 0 exit status, got non-zero" >&2 | ||
exit 1 | ||
fi | ||
|
||
assert_file_exists "$TEST_TMPDIR/auracle-git/PKGBUILD" | ||
assert_directory_exists "$TEST_TMPDIR/auracle-git/.git" |
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,40 @@ | ||
#!/bin/bash | ||
|
||
find_build_directory() { | ||
local build_dirs=(*/.ninja_log) | ||
|
||
if [[ ! -e ${build_dirs[0]} ]]; then | ||
echo "error: No build directory found. Have you run 'meson build' yet?" >&2 | ||
return 1 | ||
elif (( ${#build_dirs[*]} > 1 )); then | ||
echo "error: Multiple build directories found. Unable to proceed." >&2 | ||
return 1 | ||
fi | ||
|
||
printf '%s\n' "${build_dirs[0]%/*}" | ||
} | ||
|
||
assert_directory_exists() { | ||
if [[ ! -d $1 ]]; then | ||
printf 'FAIL: expected "%s", but not found\n' "$1" >&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
assert_file_exists() { | ||
if [[ ! -f $1 ]]; then | ||
printf 'FAIL: expected "%s", but not found\n' "$1" >&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
auracle() { | ||
"$AURACLE_BIN" -C "$TEST_TMPDIR" "$@" 2>/dev/null | ||
} | ||
|
||
BUILD_DIR=$(find_build_directory) || exit 1 | ||
AURACLE_BIN=$BUILD_DIR/auracle | ||
|
||
TEST_TMPDIR=$(mktemp -d) | ||
trap 'rm -rf "$TEST_TMPDIR"' EXIT | ||
|
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,17 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC1090 | ||
source "${0%/*}/common" | ||
|
||
if ! auracle download pkgfile-git; then | ||
echo "FAIL: expected 0 exit status, got non-zero" >&2 | ||
exit 1 | ||
fi | ||
assert_file_exists "$TEST_TMPDIR/pkgfile-git/PKGBUILD" | ||
|
||
if ! auracle download -r auracle-git; then | ||
echo "FAIL: expected 0 exit status, got non-zero" >&2 | ||
exit 1 | ||
fi | ||
assert_file_exists "$TEST_TMPDIR/auracle-git/PKGBUILD" | ||
assert_file_exists "$TEST_TMPDIR/nlohmann-json/PKGBUILD" |
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,20 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC1090 | ||
source "${0%/*}/common" | ||
|
||
if ! out=$(auracle rawsearch aura | jq .resultcount 2>&1) && (( out > 0 )); then | ||
echo "FAIL: expected valid JSON, but got: $out" >&2 | ||
exit 1 | ||
fi | ||
|
||
if ! out=$(auracle rawsearch auracle-git | jq .resultcount 2>&1) || (( out != 1 )); then | ||
echo "FAIL: expected valid JSON with resultcount of 1, but got: $out" >&2 | ||
exit 1 | ||
fi | ||
|
||
if ! out=$(auracle rawsearch --searchby maintainer falconindy | jq -r '.results[].Name') || | ||
[[ $out != *auracle-git* ]]; then | ||
echo "FAIL: expected valid JSON with at least 'auracle-git', but got: $out" >&2 | ||
exit 1 | ||
fi |
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
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
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
Oops, something went wrong.