postit-debian: support POSTIT_GIT_TAG as a tag (not just a branch)

The previous override_dh_auto_build used 'git clone --branch <tag>'
which only accepts branch names. Feeding it 1.0.1-rc02 (a tag,
not yet pushed to origin) failed with 'La branche distante
1.0.1-rc02 n'a pas ete trouvee' and aborted the package build.

Switch to a 'git init + remote add + fetch --depth=1 origin <ref>
+ checkout FETCH_HEAD' sequence, which works for both branches
and tags, including local-only tags fetched via file:// (the
typical RC-staging workflow: 'git tag' on the local checkout,
then 'make POSTIT_GIT_URL=file:///... POSTIT_GIT_TAG=<tag>'
before pushing).

The fetch error now carries a diagnostic that points the operator
at the file:// override and at the missing 'git push'.

Adds tests/test-fetch-upstream.sh with four cases against the
real pazof/yavsc remote and a synthetic local repo: tag on
GitHub, branch on GitHub, .git reuse, and tag via file://.
Wired into 'make test'.
This commit is contained in:
Lum 2026-06-28 13:47:15 +01:00
commit 7f57952a92
3 changed files with 202 additions and 8 deletions

31
debian/rules vendored
View file

@ -55,15 +55,32 @@ override_dh_auto_build:
sed 's/@VERSION@/$(POSTIT_GIT_TAG)/g' \
$(CURDIR)/debian/changelog.in > $(CURDIR)/debian/changelog; \
fi
# 1. Fetch the upstream source.
# 1. Fetch the upstream source at POSTIT_GIT_TAG. The ref can
# be either a branch name (e.g. `main`) or a tag (e.g.
# `1.0.1-rc02`); `git fetch origin <ref>` handles both. The
# reference MUST exist on the configured POSTIT_GIT_URL
# remote (default: github.com/pazof/yavsc). If you are
# building from a tag that is only on your local clone
# (typical right after `git tag 1.0.1-rc02` and before
# `git push origin 1.0.1-rc02`), point POSTIT_GIT_URL at
# your local checkout:
# make POSTIT_GIT_URL=file:///home/paul/Workspace/yavsc \
# POSTIT_GIT_TAG=1.0.1-rc02
mkdir -p $(POSTIT_BUILD_DIR)
if [ -d $(POSTIT_SRC_DIR) ]; then \
git -C $(POSTIT_SRC_DIR) fetch --depth=1 origin $(POSTIT_GIT_TAG); \
git -C $(POSTIT_SRC_DIR) reset --hard $(POSTIT_GIT_TAG); \
else \
git clone --depth=1 --branch $(POSTIT_GIT_TAG) \
$(POSTIT_GIT_URL) $(POSTIT_SRC_DIR); \
if [ ! -d $(POSTIT_SRC_DIR)/.git ]; then \
git init -q $(POSTIT_SRC_DIR); \
git -C $(POSTIT_SRC_DIR) remote add origin $(POSTIT_GIT_URL); \
fi
if ! git -C $(POSTIT_SRC_DIR) fetch --depth=1 origin $(POSTIT_GIT_TAG); then \
echo "" >&2; \
echo " ERROR: POSTIT_GIT_TAG='$(POSTIT_GIT_TAG)' is not reachable from POSTIT_GIT_URL='$(POSTIT_GIT_URL)'." >&2; \
echo " Either push the ref to the remote first (e.g. \`git push origin $(POSTIT_GIT_TAG)\`)" >&2; \
echo " or override POSTIT_GIT_URL with a local path that has the ref, e.g." >&2; \
echo " make POSTIT_GIT_URL=file:///home/paul/Workspace/yavsc POSTIT_GIT_TAG=$(POSTIT_GIT_TAG)" >&2; \
echo "" >&2; \
exit 128; \
fi
git -C $(POSTIT_SRC_DIR) checkout -q FETCH_HEAD
# 2. Publish PostIt.Desktop for the host architecture.
# --self-contained false : rely on the system .NET