summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/gitget/gitget10
-rw-r--r--test/gitget-test.sh38
2 files changed, 45 insertions, 3 deletions
diff --git a/src/gitget/gitget b/src/gitget/gitget
index 4d127c7..c941441 100755
--- a/src/gitget/gitget
+++ b/src/gitget/gitget
@@ -116,9 +116,13 @@ download_git_bare() {
cd_safe "$dir"
# Make sure we are fetching the right repo
if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
- error "%s is not a clone of %s" "$dir" "$url"
- plain "Aborting..."
- exit 1
+ if $FORCE; then
+ git config remote.origin.url "$url"
+ else
+ error "%s is not a clone of %s" "$dir" "$url"
+ plain "Aborting..."
+ exit 1
+ fi
fi
if [[ -n $push ]] ; then
if $FORCE; then
diff --git a/test/gitget-test.sh b/test/gitget-test.sh
new file mode 100644
index 0000000..d14ce16
--- /dev/null
+++ b/test/gitget-test.sh
@@ -0,0 +1,38 @@
+#!/usr/bin/env roundup
+
+describe gitget
+. ./test-common.sh
+
+it_displays_help() {
+ LC_ALL=C gitget -h >$tmpdir/stdout 2>$tmpdir/stderr
+
+ [[ "$(sed 1q $tmpdir/stdout)" =~ Usage:.* ]]
+ empty $tmpdir/stderr
+}
+
+it_fails_with_0_args() {
+ gitget >$tmpdir/stdout 2>$tmpdir/stderr || stat=$?
+
+ [[ $stat != 0 ]]
+ empty $tmpdir/stdout
+ not empty $tmpdir/stderr
+}
+
+it_forces_url_for_bare() {
+ mkdir "$tmpdir/src"
+ cd "$tmpdir/src"
+ git init .
+ echo a > a
+ git add .
+ git commit -m 'initial commit'
+ cd ..
+ gitget bare src dst.git
+ cd dst.git
+ [[ "$(git config --get remote.origin.url)" == "$tmpdir/src" ]]
+ cd ..
+ gitget bare "file://$PWD/src" dst.git || r=$?
+ [[ $r != 0 ]]
+ gitget -f bare "file://$PWD/src" dst.git
+ cd dst.git
+ [[ "$(git config --get remote.origin.url)" == "file://$tmpdir/src" ]]
+}