Skip to content

Commit 33c3153

Browse files
authored
Merge pull request #87 from git-for-windows/support-open-pr-with-msys2-runtime
open-pr: support msys2 runtime
2 parents 51ebcc1 + 18b1452 commit 33c3153

File tree

2 files changed

+79
-5
lines changed

2 files changed

+79
-5
lines changed

.github/workflows/open-pr.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ jobs:
121121
PKGBUILD
122122
fi &&
123123
git update-index -q --refresh &&
124-
if git diff-files --exit-code
124+
if git diff-files --exit-code && git diff-index --quiet HEAD --
125125
then
126126
echo "::notice::$PACKAGE_TO_UPGRADE already at $UPGRADE_TO_VERSION"
127127
exit 0
@@ -167,10 +167,11 @@ jobs:
167167
else if (name === 'mingw-w64-pcre2') body = `See https://github.com/PCRE2Project/pcre2/blob/pcre2-${version}/ChangeLog for details.`
168168
169169
const terms = 'type:issue repo:git-for-windows/git state:open author:app/github-actions label:component-update'
170-
const { data } = await github.rest.search.issuesAndPullRequests({
171-
q: `"[New ${name.replace(/^mingw-w64-/, '')} version]" (${version} OR v${version}) in:title ${terms}`,
172-
})
173-
if (data.total_count) body = `${body ? `${body}\n\n` : ''}This closes ${data.items[0].html_url}`
170+
const [verb, q] = name === 'msys2-runtime'
171+
? ['corresponds to', `type:pr repo:git-for-windows/msys2-runtime state:open ${version}`]
172+
: ['closes', `"[New ${name.replace(/^mingw-w64-/, '')} version]" (${version} OR v${version}) in:title ${terms}`]
173+
const { data } = await github.rest.search.issuesAndPullRequests({ q })
174+
if (data.total_count) body = `${body ? `${body}\n\n` : ''}This ${verb} ${data.items[0].html_url}`
174175
} catch (e) {
175176
console.log(e)
176177
}

update-scripts/version/msys2-runtime

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/bin/sh
2+
3+
die () {
4+
echo "$*" >&2
5+
exit 1
6+
}
7+
8+
hex1='[0-9a-fA-F]'
9+
hex8="$hex1$hex1$hex1$hex1$hex1$hex1$hex1$hex1"
10+
hex40="$hex8$hex8$hex8$hex8$hex8"
11+
revision=
12+
title=
13+
set -x
14+
echo "$1"
15+
case "$1" in
16+
# 40 hexadecimal characters
17+
$hex40) revision=$1;;
18+
*) die "Usage: $0 <revision>";;
19+
esac
20+
21+
case "$revision" in
22+
$hex40) ;; # okay
23+
*) die "Invalid revision: $revision";;
24+
esac
25+
26+
# `updpkgsums` requires the bare clone `msys2-runtime` to exist
27+
git init --bare msys2-runtime &&
28+
git --git-dir=msys2-runtime config remote.origin.url https://github.com/cygwin/cygwin &&
29+
git --git-dir=msys2-runtime fetch --tags https://github.com/cygwin/cygwin &&
30+
31+
git clone --bare msys2-runtime src/msys2-runtime &&
32+
git --git-dir=src/msys2-runtime config remote.origin.url https://github.com/git-for-windows/msys2-runtime &&
33+
# pretend to be a partial clone
34+
git --git-dir=src/msys2-runtime config remote.origin.promisor true &&
35+
git --git-dir=src/msys2-runtime config remote.origin.partialCloneFilter blob:none ||
36+
die "Failed to initialize the src/msys2-runtime repository"
37+
38+
git --git-dir=src/msys2-runtime reset --soft "$revision" &&
39+
previous_commit="$(cat msys2-runtime.commit)" && {
40+
test 0 = $(git --git-dir=src/msys2-runtime rev-list --count "$revision..$previous_commit") ||
41+
die "The revision $revision is not a direct descendant of $previous_commit"
42+
} &&
43+
44+
# update pkgver if needed
45+
update_pkgver= &&
46+
pkgver=$(git --git-dir=src/msys2-runtime describe --match='cygwin-[0-9]*' "$revision") &&
47+
pkgver=${pkgver#cygwin-} &&
48+
pkgver=${pkgver%%-*} &&
49+
if test "$pkgver" != "$(sed -n 's/^pkgver=\(.*\)/\1/p' PKGBUILD)"
50+
then
51+
update_pkgver=t
52+
sed -i "s/^pkgver=.*/pkgver=$pkgver/" PKGBUILD &&
53+
# the `update-patches.sh` script requires no uncommitted changes, but it also expects
54+
# the `pkgver` to be set correctly.
55+
git commit -sm 'msys2-runtime: WIP' PKGBUILD
56+
fi &&
57+
58+
# pre-fetch the required blobs
59+
git --git-dir=src/msys2-runtime fetch origin \
60+
$(git --git-dir=src/msys2-runtime -c core.abbrev=no \
61+
log --format='%n' --raw "refs/tags/cygwin-$pkgver..$revision" ^"$revision^{/^Start.the.merging-rebase}" |
62+
cut -d ' ' -f 3,4 |
63+
tr ' ' '\n' |
64+
grep -v '^0*$' |
65+
sort |
66+
uniq) &&
67+
68+
sh -x ./update-patches.sh &&
69+
if test -n "$update_pkgver"
70+
then
71+
git reset --soft HEAD^ &&
72+
sed -i 's/^pkgrel=.*/pkgrel=1/' PKGBUILD
73+
fi

0 commit comments

Comments
 (0)