aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-05-27 13:19:51 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-05-27 13:37:27 +0200
commit6398d67067837fe2a77d5d5290fec85719a02a8c (patch)
treee3a2e6407cead893624ef8fe3e6f6d1508fafbe1
parentREADME: update URLs (diff)
downloadcgitize-6398d67067837fe2a77d5d5290fec85719a02a8c.tar.gz
cgitize-6398d67067837fe2a77d5d5290fec85719a02a8c.zip
clone to NAME.git folders
It seems to be the convention and the default behaviour of `git clone --bare`, so do that.
-rw-r--r--cgitize/cgit.py2
-rw-r--r--cgitize/repo.py17
-rw-r--r--examples/docker/cgitize.toml1
-rwxr-xr-xtest/integration/docker/test.sh2
-rwxr-xr-xtest/integration/example/test.sh6
-rwxr-xr-xtest/integration/local/test.sh2
6 files changed, 21 insertions, 9 deletions
diff --git a/cgitize/cgit.py b/cgitize/cgit.py
index dd06216..e2e872e 100644
--- a/cgitize/cgit.py
+++ b/cgitize/cgit.py
@@ -18,7 +18,7 @@ class CGitServer:
def get_clone_url(self, repo):
if self.clone_url is None:
return None
- return self.clone_url.format(repo=repo.dir)
+ return self.clone_url.format(repo=repo.url_path)
class CGitRCWriter:
diff --git a/cgitize/repo.py b/cgitize/repo.py
index 079801f..dd55b17 100644
--- a/cgitize/repo.py
+++ b/cgitize/repo.py
@@ -93,6 +93,10 @@ class Repo:
return self._name
@property
+ def namegit(self):
+ return f'{self.name}.git'
+
+ @property
def desc(self):
if self._desc is not None and self._desc:
return self._desc
@@ -124,8 +128,15 @@ class Repo:
return self.clone_url
return url_replace_auth(self.clone_url, self.url_auth)
+ def _with_dir(self, s):
+ if self._dir is None:
+ return s
+ return os.path.join(self._dir, s)
+
@property
def dir(self):
- if self._dir is None:
- return self.name
- return os.path.join(self._dir, self.name)
+ return self._with_dir(self.namegit)
+
+ @property
+ def url_path(self):
+ return self._with_dir(self.name)
diff --git a/examples/docker/cgitize.toml b/examples/docker/cgitize.toml
index 43297c8..b7b37e3 100644
--- a/examples/docker/cgitize.toml
+++ b/examples/docker/cgitize.toml
@@ -1,4 +1,5 @@
clone_via_ssh = false
+clone_url = "http://localhost/{repo}"
[github]
diff --git a/test/integration/docker/test.sh b/test/integration/docker/test.sh
index 239385e..7b5b4df 100755
--- a/test/integration/docker/test.sh
+++ b/test/integration/docker/test.sh
@@ -162,7 +162,7 @@ verify() {
echo Checking the pulled repository
echo ----------------------------------------------------------------------
- pushd -- "$script_dir/cgitize/output/test_repo" > /dev/null
+ pushd -- "$script_dir/cgitize/output/test_repo.git" > /dev/null
git log --oneline
popd > /dev/null
}
diff --git a/test/integration/example/test.sh b/test/integration/example/test.sh
index 6e38729..e22cec1 100755
--- a/test/integration/example/test.sh
+++ b/test/integration/example/test.sh
@@ -67,7 +67,7 @@ verify_origin() {
echo "Verifying origin: $repo"
echo ----------------------------------------------------------------------
- local repo_dir="$output_dir/$repo"
+ local repo_dir="$output_dir/$repo.git"
local actual
actual="$( GIT_DIR="$repo_dir" git config --get remote.origin.url )"
@@ -90,7 +90,7 @@ verify_repos() {
echo "Verifying repository: $repo"
echo ----------------------------------------------------------------------
- local repo_dir="$output_dir/$repo"
+ local repo_dir="$output_dir/$repo.git"
GIT_DIR="$repo_dir" git rev-parse HEAD > /dev/null
echo 'HEAD is fine.'
@@ -111,7 +111,7 @@ verify_no_repos() {
echo "Verifying repository doesn't exist: $repo"
echo ----------------------------------------------------------------------
- local repo_dir="$output_dir/$repo"
+ local repo_dir="$output_dir/$repo.git"
if [ -e "$repo_dir" ]; then
echo "Exists, but it shouldn't."
return 1
diff --git a/test/integration/local/test.sh b/test/integration/local/test.sh
index 3c73543..68c78ec 100755
--- a/test/integration/local/test.sh
+++ b/test/integration/local/test.sh
@@ -141,7 +141,7 @@ verify_commits() {
# doesn't work: https://stackoverflow.com/q/4072984/514684
# TODO: figure this out?
pushd -- "$output_dir" > /dev/null &&
- cd -- test_repo &&
+ cd -- test_repo.git &&
local output &&
output="$( git log --oneline )" &&
echo "$output" &&