Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umpf: add new flag to insert 'Upstream-Status: Pending' lines to all patches #36

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tests = [
'umpf-series-tag',
'umpf-build-tag',
'umpf-build-tag-identical',
'umpf-build-tag-upstreamstatus',
'umpf-series-tag-continue',
'umpf-series-tag-rerere',
'umpf-series-tag-continue-flags',
Expand Down
11 changes: 11 additions & 0 deletions tests/series-upstreamstatus-v2.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# umpf-base: base
# umpf-flags: upstreamstatus=insert
# umpf-name: name
# umpf-version: name/20221209-2
# umpf-topic: a
# umpf-hashinfo: f46ed0419d2c31ed10f978cc461e0d1ae4b3b426
# umpf-topic-range: d306da785d874c09b89264d3f71632bc14bfe51f..121863a14e5f5430eea076205d50d668aeb66aa3
# umpf-topic: b
# umpf-hashinfo: 3755a03cf640725df1aeb13789cba87154a47b04
# umpf-topic-range: 121863a14e5f5430eea076205d50d668aeb66aa3..83884ac6f3420eb1b1c98628b64dc1a77b6c1136
# umpf-end
9 changes: 9 additions & 0 deletions tests/umpf-build-tag-upstreamstatus
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
#
# Test creating an umpf tag from an umpf build with "umpf tag".
#

umpf tag umpf-build --version=2 --remote=origin --base=base --name=name --flags upstreamstatus=insert

git log --format=%B -n 1 | grep "^# umpf-" > series.tag
diff -u ${TEST_DIR}/series-upstreamstatus-v2.ref series.tag
46 changes: 43 additions & 3 deletions umpf
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,18 @@ GIT_DIR="${GIT_DIR:-.git}"
STATE="${GIT_DIR}/umpf"

### flags ####
SUPPORTED_FLAGS=("extraversion")
SUPPORTED_FLAGS=("extraversion" "upstreamstatus")

declare -A flag_extraversion

flag_extraversion[val]="replace"
flag_extraversion[values]="replace conflictfree"

declare -A flag_upstreamstatus

flag_upstreamstatus[val]="none"
flag_upstreamstatus[values]="none insert"

##############

info() {
Expand Down Expand Up @@ -1105,7 +1111,30 @@ rebase_branch() {
committerdate="$(${GIT} log -1 --format=%cd --date=raw "$(<"${STATE}/base")")"
fi

if ! FILTER_BRANCH_SQUELCH_WARNING=1 "${GIT}" filter-branch -f --env-filter "GIT_COMMITTER_DATE='$committerdate'; GIT_COMMITTER_NAME=umpf; [email protected]" "$(<"${STATE}/prev_head").."; then
declare -a msg_filter
if [ "${flag_upstreamstatus[val]}" = "insert" ]; then
msg_filter=(
--msg-filter
"awk '
/^Upstream-Status:/ {
done=1
}
/^[^\s]*-by:/ {
if (!done) {
print \"Upstream-Status: Pending\n\"
done=1
}
}
{
print \$0
}
END {
if (!done)
print \"\nUpstream-Status: Pending\"
}'" )
fi

if ! FILTER_BRANCH_SQUELCH_WARNING=1 "${GIT}" filter-branch -f "${msg_filter[@]}" --env-filter "GIT_COMMITTER_DATE='$committerdate'; GIT_COMMITTER_NAME=umpf; [email protected]" "$(<"${STATE}/prev_head").."; then
bailout "rewrite for reproducible commit-ish failed."
fi
echo "# umpf-topic-range: $(<"${STATE}/prev_head")..$(${GIT} rev-parse HEAD)" >&${series_out}
Expand Down Expand Up @@ -1233,7 +1262,13 @@ rebase_end() {
fi
if ! ${GIT} diff-index --cached --quiet HEAD --; then
local tagname="$(<"${STATE}/tag")"
${GIT} commit --no-verify -m "Release ${tagname}"
local extra_message
if [ "${flag_upstreamstatus[val]}" = "insert" ]; then
extra_message="

Upstream-Status: Inappropriate [autogenerated]"
fi
${GIT} commit --no-verify -m "Release ${tagname}${extra_message}"
echo "# umpf-release: ${tagname}" >&${series_out}
echo "# umpf-topic-range: $(<"${STATE}/prev_head")..$(${GIT} rev-parse HEAD)" >&${series_out}
fi
Expand Down Expand Up @@ -1428,6 +1463,11 @@ run_format_patch() {
done
if ${BB}; then
cp "${STATE}/series.next" "${PATCH_DIR}/series.inc"
if [ "${flag_upstreamstatus[val]}" != "insert" ]; then
info
info "Note: Patches are created without Upstream-Status!"
info
fi
elif ${NIX}; then
cp "${STATE}/series.next" "${PATCH_DIR}/series.nix"
else
Expand Down
Loading