commit 5ecab2777d7705e4e9e6d6e0bc09bd25443d01db
parent 94d6bfdb27b90a5f6d20c2e19146e8d96ad23102
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Tue, 26 May 2026 16:23:05 +0200
git-publish: add more tests
Diffstat:
| M | test_publish.sh | | | 68 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- |
1 file changed, 65 insertions(+), 3 deletions(-)
diff --git a/test_publish.sh b/test_publish.sh
@@ -67,7 +67,7 @@ check_www_content()
########################################################################
# Create bare repository
mkdir -p "${git}"
-git init --bare "${git}"
+git init --initial-branch=master --bare "${git}"
# Create the repository content
mkdir -p "${repo}"
@@ -77,7 +77,7 @@ printf '%s' "${cookie}" > "${repo}/cookie.txt"
# Configure the directory as a git working directory, commit its
# content and push it to the remote repository
cd "${repo}"
-git init
+git init --initial-branch=master
git config --local user.name "Mr Untel"
git config --local user.email "mr@untel.fr"
git add README cookie.txt
@@ -105,11 +105,23 @@ check_git_content "file://${srv}/git/${name}.git"
check_git_content "file://${git}"
check_www_content
-# Unpublish the repository
+# Try to publish an already published repository
+git publish \
+ -g "${srv}/git" \
+ -w "${srv}/www" \
+ -u "http://mr.untel.fr/" \
+ "${git}"
+
+# Unpublish
GIT_PUBLISH_DIR_GIT="${srv}/git" \
GIT_PUBLISH_DIR_WWW="${srv}/www" \
git publish -d "${git}"
+# Attempting to unpublish a non-published repository results in an error
+GIT_PUBLISH_DIR_GIT="${srv}/git" \
+GIT_PUBLISH_DIR_WWW="${srv}/www" \
+git publish -d "${git}" && false || true
+
# The published content should be removed
[ ! -e "${srv}/git/${name}.git" ]
[ ! -e "${srv}/www/${name}" ]
@@ -139,6 +151,20 @@ check_git_content "file://${srv}/git/${name}.git"
check_git_content "file://${git}"
check_www_content
+# Republish the same repo but without the -m option.
+# Check that the public repo is thus a symbolic link to the original
+# repository
+git publish "${git}"
+[ -L "${srv}/git/${name}.git" ]
+[ -d "${git}" ] && [ ! -L "${git}" ]
+
+# Republish the same repo with the -m option.
+# Check that the original path is a symbolic link to the public
+# repository
+git publish -m "${git}"
+[ -d "${srv}/git/${name}.git" ] && [ ! -L "${srv}/git/${name}.git" ]
+[ -L "${git}" ]
+
# Unpublish the repository
git publish -d "${git}"
@@ -152,4 +178,40 @@ git publish -d "${git}"
check_git_content "file://${git}"
+########################################################################
+# Prevent the publication of the repository
+########################################################################
+touch "${git}/publication_ban"
+
+git publish "${git}"
+[ ! -e "${srv}/git/${name}.git" ]
+[ ! -e "${srv}/www/${name}" ]
+
+git publish -m "${git}"
+[ ! -e "${srv}/git/${name}.git" ]
+[ ! -e "${srv}/www/${name}" ]
+
+rm "${git}/publication_ban"
+
+########################################################################
+# Switch from the original repository to the published repository
+########################################################################
+# Publish the repository and try to unpublish the original repository.
+# The original repository has been deleted! But the one that was
+# published should still be valid as it was considered as the original
+# one .
+git publish -g "${srv}/git/" "${git}"
+git publish -g "$(dirname "${git}")" -d "${srv}/git/${name}.git"
+[ ! -e "${git}" ]
+check_git_content "file://${srv}/git/${name}.git"
+mv "${srv}/git/${name}.git" "${git}"
+check_git_content "file://${git}"
+
+# Same as above but the published repository is the original one moved
+# to the public directory
+git publish -g "${srv}/git/" -m "${git}"
+git publish -g "$(dirname "${git}")" -d "${srv}/git/${name}.git"
+[ ! -e "${git}" ]
+check_git_content "file://${srv}/git/${name}.git"
+
die 0