Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] CI: check reverts
@ 2022-09-16  3:29 sgn
  2022-09-16  4:08 ` [PR REVIEW] " classabbyamp
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sgn @ 2022-09-16  3:29 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages check-reverts
https://github.com/void-linux/void-packages/pull/39309

CI: check reverts
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39309.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-check-reverts-39309.patch --]
[-- Type: text/x-diff, Size: 9027 bytes --]

From 200cbe4e9d78e8489e0d9d40aa9855a5758c3801 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 08:50:39 +0700
Subject: [PATCH 1/4] common: simplify logic to find git

From chroot-git 2.33.1, we always have an executable named git
for other build infrastructure and lints.

Let's remove the shenanegan to find which git to be used, prepend the
path to chroot-git's git into $PATH, and let's the shell call the
correct git for us instead.
---
 .github/workflows/cycles.yml       |  8 ++------
 common/scripts/lint-commits        | 12 ++++++------
 common/scripts/lint-version-change | 12 +++++-------
 common/travis/changed_templates.sh | 12 ++++--------
 common/travis/fetch_upstream.sh    | 10 +++-------
 5 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/.github/workflows/cycles.yml b/.github/workflows/cycles.yml
index 3f85ac6fa74a..7d781076dbe9 100644
--- a/.github/workflows/cycles.yml
+++ b/.github/workflows/cycles.yml
@@ -33,13 +33,9 @@ jobs:
          common/travis/prepare.sh
       - name: Find cycles and open issues
         run: |
-         if command -v chroot-git >/dev/null 2>&1; then
-             GIT_CMD=$(command -v chroot-git)
-         elif command -v git >/dev/null 2>&1; then
-            GIT_CMD=$(command -v git)
-         fi
+         PATH="/usr/libexec/chroot-git:$PATH"
          # required by git 2.35.2+
-         $GIT_CMD config --global --add safe.directory "$PWD"
+         git config --global --add safe.directory "$PWD"
          common/scripts/xbps-cycles.py | tee cycles
          grep 'Cycle:' cycles | while read -r line; do
              if gh issue list -R "$GITHUB_REPOSITORY" -S "$line" | grep .; then
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
index 7207ed81d5aa..aa4081833528 100755
--- a/common/scripts/lint-commits
+++ b/common/scripts/lint-commits
@@ -5,18 +5,18 @@ die() {
 	exit 1
 }
 
-GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
-GIT_CMD=$(command -v git 2>/dev/null) ||
+PATH="/usr/libexec/chroot-git:$PATH"
+command -v git 2>/dev/null ||
 die "neither chroot-git nor git could be found!"
 
 rev_parse() {
 	if [ -n "$1" ]; then
-		"$GIT_CMD" rev-parse --verify "$1"
+		git rev-parse --verify "$1"
 	else
 		shift
 		while test "$#" != 0
 		do
-			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			git rev-parse --verify "$1" 2>/dev/null && return
 			shift
 		done
 		return 1
@@ -27,9 +27,9 @@ base=$(rev_parse "$1" FETCH_HEAD ORIG_HEAD) || die "base commit not found"
 tip=$(rev_parse "$2" HEAD) || die "tip commit not found"
 status=0
 
-for cmt in $("$GIT_CMD" rev-list --abbrev-commit $base..$tip)
+for cmt in $(git rev-list --abbrev-commit $base..$tip)
 do
-	"$GIT_CMD" cat-file commit "$cmt" |
+	git cat-file commit "$cmt" |
 	awk -vC="$cmt" '
 	# skip header
 	/^$/ && !msg { msg = 1; next }
diff --git a/common/scripts/lint-version-change b/common/scripts/lint-version-change
index 5e9687799384..96263ba55ae2 100755
--- a/common/scripts/lint-version-change
+++ b/common/scripts/lint-version-change
@@ -13,20 +13,18 @@ if ! [ "$base_rev" ]; then
 	die "usage: $0 TEMPLATE BASE-REVISION [TIP-REVISION]"
 fi
 
-if command -v chroot-git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v chroot-git)
-elif command -v git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v git)
-else
+PATH="/usr/libexec/chroot-git:$PATH"
+if ! command -v git >/dev/null 2>&1; then
 	die "neither chroot-git nor git could be found"
 fi
 
 scan() {
 	rx="$1" msg="$2"
 	template_path=$template
+	maybe_git=
 	if [ "$tip_rev" ]; then
 		template_path="${tip_rev}:${template}"
-		maybe_git="$GIT_CMD"
+		maybe_git="git"
 		revspec="[^:]*:"
 	fi
 	$maybe_git grep -P -Hn -e "$rx" "$template_path" |
@@ -37,7 +35,7 @@ scan() {
 show_template() {
 	rev="$1"
 	if [ "$rev" ]; then
-		$GIT_CMD cat-file blob "${rev}:${template}" 2>/dev/null
+		git cat-file blob "${rev}:${template}" 2>/dev/null
 	else
 		cat "${template}" 2>/dev/null
 	fi
diff --git a/common/travis/changed_templates.sh b/common/travis/changed_templates.sh
index 686436ce4327..3c8acf787637 100755
--- a/common/travis/changed_templates.sh
+++ b/common/travis/changed_templates.sh
@@ -2,19 +2,15 @@
 #
 # changed_templates.sh
 
-if command -v chroot-git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v chroot-git)
-elif command -v git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v git)
-fi
+PATH="/usr/libexec/chroot-git:$PATH"
 
-tip="$($GIT_CMD rev-list -1 --parents HEAD)"
+tip="$(git rev-list -1 --parents HEAD)"
 case "$tip" in
 	*" "*" "*) tip="${tip##* }" ;;
 	*)         tip="${tip%% *}" ;;
 esac
 
-base="$($GIT_CMD merge-base FETCH_HEAD "$tip")" || {
+base="$(git merge-base FETCH_HEAD "$tip")" || {
 	echo "Your branches is based on too old copy."
 	echo "Please rebase to newest copy."
 	exit 1
@@ -23,7 +19,7 @@ base="$($GIT_CMD merge-base FETCH_HEAD "$tip")" || {
 echo "$base $tip" >/tmp/revisions
 
 /bin/echo -e '\x1b[32mChanged packages:\x1b[0m'
-$GIT_CMD diff-tree -r --no-renames --name-only --diff-filter=AM \
+git diff-tree -r --no-renames --name-only --diff-filter=AM \
 	"$base" "$tip" \
 	-- 'srcpkgs/*/template' |
 	cut -d/ -f 2 |
diff --git a/common/travis/fetch_upstream.sh b/common/travis/fetch_upstream.sh
index 049cfd69e54d..40c136f3857c 100755
--- a/common/travis/fetch_upstream.sh
+++ b/common/travis/fetch_upstream.sh
@@ -2,14 +2,10 @@
 #
 # changed_templates.sh
 
-if command -v chroot-git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v chroot-git)
-elif command -v git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v git)
-fi
+PATH="/usr/libexec/chroot-git:$PATH"
 
 # required by git 2.35.2+
-$GIT_CMD config --global --add safe.directory "$PWD"
+git config --global --add safe.directory "$PWD"
 
 /bin/echo -e '\x1b[32mFetching upstream...\x1b[0m'
-$GIT_CMD fetch --depth 200 https://github.com/void-linux/void-packages.git master
+git fetch --depth 200 https://github.com/void-linux/void-packages.git master

From f29c00b896f4d8cf591c238150231a33df8c24d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 09:18:27 +0700
Subject: [PATCH 2/4] changed_templates: explain what has been done

---
 common/travis/changed_templates.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/travis/changed_templates.sh b/common/travis/changed_templates.sh
index 3c8acf787637..534cd97a12b1 100755
--- a/common/travis/changed_templates.sh
+++ b/common/travis/changed_templates.sh
@@ -6,7 +6,9 @@ PATH="/usr/libexec/chroot-git:$PATH"
 
 tip="$(git rev-list -1 --parents HEAD)"
 case "$tip" in
+	# This is a merge commit, pick last parent
 	*" "*" "*) tip="${tip##* }" ;;
+	# This is a non-merge commit, pick itself
 	*)         tip="${tip%% *}" ;;
 esac
 

From 58f6e749e308bbfb0e4927b1e794d41ef3d8cd18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 09:55:49 +0700
Subject: [PATCH 3/4] lint-version-change: correctly print multiline variables

---
 common/scripts/lint-version-change | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/scripts/lint-version-change b/common/scripts/lint-version-change
index 96263ba55ae2..1b276062a4dd 100755
--- a/common/scripts/lint-version-change
+++ b/common/scripts/lint-version-change
@@ -43,7 +43,10 @@ show_template() {
 
 show_template_var() {
 	rev="$1" var="$2"
-	show_template "$rev" | grep -Po '^'${var}'=\K.*'
+	(
+		show_template "$rev"
+		printf '%s\n' "printf '%s\\n' \"\$${var}\""
+	) | bash
 }
 
 revision_reset() {

From fe0412e467e38be245640d0f4651eaaa3cff4395 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 10:27:35 +0700
Subject: [PATCH 4/4] lint-version: check reverts

---
 common/scripts/lint-version-change | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/common/scripts/lint-version-change b/common/scripts/lint-version-change
index 1b276062a4dd..57beb5abcdd2 100755
--- a/common/scripts/lint-version-change
+++ b/common/scripts/lint-version-change
@@ -73,6 +73,32 @@ reverts_on_downgrade() {
 	esac
 }
 
+check_revert() {
+	for vr in $reverts; do
+		xbps-uhelper cmpver "${vr%_*}" "${version}"
+		case "$?" in
+		0)
+			echo "version: ${version} in \$reverts"
+			status=1
+			;;
+		1)
+			echo "remove ${version} from \$reverts"
+			status=1
+			;;
+		esac
+	done
+	for vr in $prev_reverts; do
+		if ! xbps-uhelper cmpver "$version" "${vr%_*}"; then
+			continue
+		fi
+		if [ $revision -gt "${vr##*_}" ]; then
+			continue
+		fi
+		echo "undo a revert with same revision as before"
+		status=1
+	done
+}
+
 version_change() {
 	version="$(show_template_var "$tip_rev" version)"
 	revision="$(show_template_var "$tip_rev" revision)"
@@ -84,6 +110,7 @@ version_change() {
 		1) revision_reset;;
 		-1|255) reverts_on_downgrade;;
 	esac
+	check_revert
 }
 
 version_change

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR REVIEW] CI: check reverts
  2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
@ 2022-09-16  4:08 ` classabbyamp
  2022-09-16  4:08 ` classabbyamp
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: classabbyamp @ 2022-09-16  4:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 217 bytes --]

New review comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/39309#discussion_r972593053

Comment:
```suggestion
			scan "^version=" "${version} in \$reverts"
```

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR REVIEW] CI: check reverts
  2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
  2022-09-16  4:08 ` [PR REVIEW] " classabbyamp
@ 2022-09-16  4:08 ` classabbyamp
  2022-09-16  4:08 ` classabbyamp
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: classabbyamp @ 2022-09-16  4:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 230 bytes --]

New review comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/39309#discussion_r972593941

Comment:
```suggestion
		scan "^revision=" "revision was previously in \$reverts"
```

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR REVIEW] CI: check reverts
  2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
  2022-09-16  4:08 ` [PR REVIEW] " classabbyamp
  2022-09-16  4:08 ` classabbyamp
@ 2022-09-16  4:08 ` classabbyamp
  2022-09-16  6:01 ` classabbyamp
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: classabbyamp @ 2022-09-16  4:08 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]

New review comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/39309#discussion_r972593199

Comment:
```suggestion
			scan "^version=" "remove ${version} from \$reverts"
```

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR REVIEW] CI: check reverts
  2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
                   ` (2 preceding siblings ...)
  2022-09-16  4:08 ` classabbyamp
@ 2022-09-16  6:01 ` classabbyamp
  2022-09-16  7:06 ` [PR PATCH] [Updated] " sgn
  2022-09-17 16:32 ` [PR PATCH] [Merged]: " sgn
  5 siblings, 0 replies; 7+ messages in thread
From: classabbyamp @ 2022-09-16  6:01 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 205 bytes --]

New review comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/39309#discussion_r972637990

Comment:
```suggestion
command -v git >/dev/null 2>&1 ||
```

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR PATCH] [Updated] CI: check reverts
  2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
                   ` (3 preceding siblings ...)
  2022-09-16  6:01 ` classabbyamp
@ 2022-09-16  7:06 ` sgn
  2022-09-17 16:32 ` [PR PATCH] [Merged]: " sgn
  5 siblings, 0 replies; 7+ messages in thread
From: sgn @ 2022-09-16  7:06 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]

There is an updated pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages check-reverts
https://github.com/void-linux/void-packages/pull/39309

CI: check reverts
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39309.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-check-reverts-39309.patch --]
[-- Type: text/x-diff, Size: 9035 bytes --]

From 6f327d73888ac8fe202071b7ff020e826fd90994 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 08:50:39 +0700
Subject: [PATCH 1/4] common: simplify logic to find git

From chroot-git 2.33.1, we always have an executable named git
for other build infrastructure and lints.

Let's remove the shenanegan to find which git to be used, prepend the
path to chroot-git's git into $PATH, and let's the shell call the
correct git for us instead.
---
 .github/workflows/cycles.yml       |  8 ++------
 common/scripts/lint-commits        | 12 ++++++------
 common/scripts/lint-version-change | 12 +++++-------
 common/travis/changed_templates.sh | 12 ++++--------
 common/travis/fetch_upstream.sh    | 10 +++-------
 5 files changed, 20 insertions(+), 34 deletions(-)

diff --git a/.github/workflows/cycles.yml b/.github/workflows/cycles.yml
index 3f85ac6fa74a..7d781076dbe9 100644
--- a/.github/workflows/cycles.yml
+++ b/.github/workflows/cycles.yml
@@ -33,13 +33,9 @@ jobs:
          common/travis/prepare.sh
       - name: Find cycles and open issues
         run: |
-         if command -v chroot-git >/dev/null 2>&1; then
-             GIT_CMD=$(command -v chroot-git)
-         elif command -v git >/dev/null 2>&1; then
-            GIT_CMD=$(command -v git)
-         fi
+         PATH="/usr/libexec/chroot-git:$PATH"
          # required by git 2.35.2+
-         $GIT_CMD config --global --add safe.directory "$PWD"
+         git config --global --add safe.directory "$PWD"
          common/scripts/xbps-cycles.py | tee cycles
          grep 'Cycle:' cycles | while read -r line; do
              if gh issue list -R "$GITHUB_REPOSITORY" -S "$line" | grep .; then
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
index 7207ed81d5aa..f372deb820af 100755
--- a/common/scripts/lint-commits
+++ b/common/scripts/lint-commits
@@ -5,18 +5,18 @@ die() {
 	exit 1
 }
 
-GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
-GIT_CMD=$(command -v git 2>/dev/null) ||
+PATH="/usr/libexec/chroot-git:$PATH"
+command -v git >/dev/null 2>&1 ||
 die "neither chroot-git nor git could be found!"
 
 rev_parse() {
 	if [ -n "$1" ]; then
-		"$GIT_CMD" rev-parse --verify "$1"
+		git rev-parse --verify "$1"
 	else
 		shift
 		while test "$#" != 0
 		do
-			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			git rev-parse --verify "$1" 2>/dev/null && return
 			shift
 		done
 		return 1
@@ -27,9 +27,9 @@ base=$(rev_parse "$1" FETCH_HEAD ORIG_HEAD) || die "base commit not found"
 tip=$(rev_parse "$2" HEAD) || die "tip commit not found"
 status=0
 
-for cmt in $("$GIT_CMD" rev-list --abbrev-commit $base..$tip)
+for cmt in $(git rev-list --abbrev-commit $base..$tip)
 do
-	"$GIT_CMD" cat-file commit "$cmt" |
+	git cat-file commit "$cmt" |
 	awk -vC="$cmt" '
 	# skip header
 	/^$/ && !msg { msg = 1; next }
diff --git a/common/scripts/lint-version-change b/common/scripts/lint-version-change
index 5e9687799384..96263ba55ae2 100755
--- a/common/scripts/lint-version-change
+++ b/common/scripts/lint-version-change
@@ -13,20 +13,18 @@ if ! [ "$base_rev" ]; then
 	die "usage: $0 TEMPLATE BASE-REVISION [TIP-REVISION]"
 fi
 
-if command -v chroot-git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v chroot-git)
-elif command -v git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v git)
-else
+PATH="/usr/libexec/chroot-git:$PATH"
+if ! command -v git >/dev/null 2>&1; then
 	die "neither chroot-git nor git could be found"
 fi
 
 scan() {
 	rx="$1" msg="$2"
 	template_path=$template
+	maybe_git=
 	if [ "$tip_rev" ]; then
 		template_path="${tip_rev}:${template}"
-		maybe_git="$GIT_CMD"
+		maybe_git="git"
 		revspec="[^:]*:"
 	fi
 	$maybe_git grep -P -Hn -e "$rx" "$template_path" |
@@ -37,7 +35,7 @@ scan() {
 show_template() {
 	rev="$1"
 	if [ "$rev" ]; then
-		$GIT_CMD cat-file blob "${rev}:${template}" 2>/dev/null
+		git cat-file blob "${rev}:${template}" 2>/dev/null
 	else
 		cat "${template}" 2>/dev/null
 	fi
diff --git a/common/travis/changed_templates.sh b/common/travis/changed_templates.sh
index 686436ce4327..3c8acf787637 100755
--- a/common/travis/changed_templates.sh
+++ b/common/travis/changed_templates.sh
@@ -2,19 +2,15 @@
 #
 # changed_templates.sh
 
-if command -v chroot-git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v chroot-git)
-elif command -v git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v git)
-fi
+PATH="/usr/libexec/chroot-git:$PATH"
 
-tip="$($GIT_CMD rev-list -1 --parents HEAD)"
+tip="$(git rev-list -1 --parents HEAD)"
 case "$tip" in
 	*" "*" "*) tip="${tip##* }" ;;
 	*)         tip="${tip%% *}" ;;
 esac
 
-base="$($GIT_CMD merge-base FETCH_HEAD "$tip")" || {
+base="$(git merge-base FETCH_HEAD "$tip")" || {
 	echo "Your branches is based on too old copy."
 	echo "Please rebase to newest copy."
 	exit 1
@@ -23,7 +19,7 @@ base="$($GIT_CMD merge-base FETCH_HEAD "$tip")" || {
 echo "$base $tip" >/tmp/revisions
 
 /bin/echo -e '\x1b[32mChanged packages:\x1b[0m'
-$GIT_CMD diff-tree -r --no-renames --name-only --diff-filter=AM \
+git diff-tree -r --no-renames --name-only --diff-filter=AM \
 	"$base" "$tip" \
 	-- 'srcpkgs/*/template' |
 	cut -d/ -f 2 |
diff --git a/common/travis/fetch_upstream.sh b/common/travis/fetch_upstream.sh
index 049cfd69e54d..40c136f3857c 100755
--- a/common/travis/fetch_upstream.sh
+++ b/common/travis/fetch_upstream.sh
@@ -2,14 +2,10 @@
 #
 # changed_templates.sh
 
-if command -v chroot-git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v chroot-git)
-elif command -v git >/dev/null 2>&1; then
-	GIT_CMD=$(command -v git)
-fi
+PATH="/usr/libexec/chroot-git:$PATH"
 
 # required by git 2.35.2+
-$GIT_CMD config --global --add safe.directory "$PWD"
+git config --global --add safe.directory "$PWD"
 
 /bin/echo -e '\x1b[32mFetching upstream...\x1b[0m'
-$GIT_CMD fetch --depth 200 https://github.com/void-linux/void-packages.git master
+git fetch --depth 200 https://github.com/void-linux/void-packages.git master

From 5512deafb70f4fca39f13ef59bbacb858f4b4d24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 09:18:27 +0700
Subject: [PATCH 2/4] changed_templates: explain what has been done

---
 common/travis/changed_templates.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/travis/changed_templates.sh b/common/travis/changed_templates.sh
index 3c8acf787637..534cd97a12b1 100755
--- a/common/travis/changed_templates.sh
+++ b/common/travis/changed_templates.sh
@@ -6,7 +6,9 @@ PATH="/usr/libexec/chroot-git:$PATH"
 
 tip="$(git rev-list -1 --parents HEAD)"
 case "$tip" in
+	# This is a merge commit, pick last parent
 	*" "*" "*) tip="${tip##* }" ;;
+	# This is a non-merge commit, pick itself
 	*)         tip="${tip%% *}" ;;
 esac
 

From 1d9b53c01838a99bf4b16312acfa31abb12e6736 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 09:55:49 +0700
Subject: [PATCH 3/4] lint-version-change: correctly print multiline variables

---
 common/scripts/lint-version-change | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/scripts/lint-version-change b/common/scripts/lint-version-change
index 96263ba55ae2..1b276062a4dd 100755
--- a/common/scripts/lint-version-change
+++ b/common/scripts/lint-version-change
@@ -43,7 +43,10 @@ show_template() {
 
 show_template_var() {
 	rev="$1" var="$2"
-	show_template "$rev" | grep -Po '^'${var}'=\K.*'
+	(
+		show_template "$rev"
+		printf '%s\n' "printf '%s\\n' \"\$${var}\""
+	) | bash
 }
 
 revision_reset() {

From a12aaf0a7ecc8826894205d1aad45ecae85d61d0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Fri, 16 Sep 2022 10:27:35 +0700
Subject: [PATCH 4/4] lint-version: check reverts

---
 common/scripts/lint-version-change | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/common/scripts/lint-version-change b/common/scripts/lint-version-change
index 1b276062a4dd..22a70dc660b9 100755
--- a/common/scripts/lint-version-change
+++ b/common/scripts/lint-version-change
@@ -73,6 +73,32 @@ reverts_on_downgrade() {
 	esac
 }
 
+check_revert() {
+	for vr in $reverts; do
+		xbps-uhelper cmpver "${vr%_*}" "${version}"
+		case "$?" in
+		0)
+			scan '^version=' 'in $reverts'
+			status=1
+			;;
+		1)
+			scan '^version=' 'remove from $reverts'
+			status=1
+			;;
+		esac
+	done
+	for vr in $prev_reverts; do
+		if ! xbps-uhelper cmpver "$version" "${vr%_*}"; then
+			continue
+		fi
+		if [ $revision -gt "${vr##*_}" ]; then
+			continue
+		fi
+		scan '^revision=' "undo a revert with same revision as before"
+		status=1
+	done
+}
+
 version_change() {
 	version="$(show_template_var "$tip_rev" version)"
 	revision="$(show_template_var "$tip_rev" revision)"
@@ -84,6 +110,7 @@ version_change() {
 		1) revision_reset;;
 		-1|255) reverts_on_downgrade;;
 	esac
+	check_revert
 }
 
 version_change

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PR PATCH] [Merged]: CI: check reverts
  2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
                   ` (4 preceding siblings ...)
  2022-09-16  7:06 ` [PR PATCH] [Updated] " sgn
@ 2022-09-17 16:32 ` sgn
  5 siblings, 0 replies; 7+ messages in thread
From: sgn @ 2022-09-17 16:32 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1097 bytes --]

There's a merged pull request on the void-packages repository

CI: check reverts
https://github.com/void-linux/void-packages/pull/39309

Description:
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-17 16:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16  3:29 [PR PATCH] CI: check reverts sgn
2022-09-16  4:08 ` [PR REVIEW] " classabbyamp
2022-09-16  4:08 ` classabbyamp
2022-09-16  4:08 ` classabbyamp
2022-09-16  6:01 ` classabbyamp
2022-09-16  7:06 ` [PR PATCH] [Updated] " sgn
2022-09-17 16:32 ` [PR PATCH] [Merged]: " sgn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).