topdir.mk: Make target git-import idempotent #129

Merged
Jan Lindemann merged 1 commit from jan/feature/20260928-topdir-mk-make-target-git-import-idempotent into master 2026-09-28 10:58:09 +02:00 AGit
Showing only changes of commit 1bab2573d0 - Show all commits

topdir.mk: Make target git-import idempotent
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m33s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 6m41s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m32s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 8m42s
CI / Packaging test (push) Successful in 0s

Target git-import adds everything it finds in the current directory. If
it's already a Git project, that fails over git commit -m "First commit".
Since it's a prerequisite of target git-init-remote, it breaks that target,
too for non-empty git repos, which isn't helpful when trying to run make
git-init-remote to publish an an already existing project.

So only do something meaningful in git-import if the project it's run in
doesn't already contain files.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann 2026-09-28 10:40:35 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -224,9 +224,12 @@ git-clone-to-remote:
make git-update-project-description
git-import: git-init git-config
git add -A
git status
git commit -am "First commit"
if ! git ls-files | grep -q .; then \
set -ex ;\
git add -A ;\
git status ;\
git commit -am "First commit" ;\
fi
git-init-remote: git-import git-clone-to-remote