Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] lint commits's message
@ 2021-05-17 15:22 sgn
  2021-05-17 15:27 ` [PR PATCH] [Updated] " sgn
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:22 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 3370 bytes --]

From 4d8d3c52fd286e8770f9a6a88ac72a0621d519c2 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH 1/2] shutils: add basic commit lint

Warn if:
* subject is longer than 50 characters
Error if:
* any lines are longer than 80 characters
* second line is not blank
---
 common/xbps-src/shutils/lint_commits.sh | 39 +++++++++++++++++++++++++
 xbps-src                                |  8 +++++
 2 files changed, 47 insertions(+)
 create mode 100755 common/xbps-src/shutils/lint_commits.sh

diff --git a/common/xbps-src/shutils/lint_commits.sh b/common/xbps-src/shutils/lint_commits.sh
new file mode 100755
index 000000000000..9e5ec3a57ffd
--- /dev/null
+++ b/common/xbps-src/shutils/lint_commits.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+lint_commits() {
+	local base="$1"
+	local status=0
+	local cmt
+	if [ -n "$base" ]; then
+		base=$("$XBPS_GIT_CMD" rev-parse --verify "$base") ||
+			return
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify FETCH_HEAD 2>/dev/null); then
+		:
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify ORIG_HEAD 2>/dev/null); then
+		:
+	else
+		echo base commit not found >&2
+		exit 1
+	fi
+
+	for cmt in $("$XBPS_GIT_CMD" rev-list --reverse --abbrev-commit "$base"..HEAD)
+	do
+		"$XBPS_GIT_CMD" cat-file commit "$cmt" |
+		awk -vC="$cmt" '
+		/^$/ && !msg { msg = 1; next }
+		!msg { next }
+		!/ / && (length > 80) { print C ": long line: " $0; exit 1 }
+		!subject {
+			if (length > 50) { print C ": subject is a bit long" }
+			# Below check is too noisy?
+			# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+			#	print C ": not new package/update/removal?"
+			# }
+			subject = 1; next
+		}
+		/^$/ { body = 1; next }
+		!body { print C ": second line must be blank"; exit 1 }
+		' || status=1
+	done
+	return $status
+}
diff --git a/xbps-src b/xbps-src
index c3cd7e5db10b..c5dbac6a90b3 100755
--- a/xbps-src
+++ b/xbps-src
@@ -141,6 +141,10 @@ update-hash-cache
 zap
     Removes a masterdir but preserving ccache, distcc and host directories.
 
+lint-commits [base-commit]
+    Do basic check on commit made from [base-commit] exclusively.
+    If [base-commit] omited, FETCH_HEAD or ORIG_HEAD will be used.
+
 Options:
 
 -1  If dependencies of target package are missing, fail instead of building them.
@@ -964,6 +968,10 @@ case "$XBPS_TARGET" in
     zap)
         masterdir_zap
         ;;
+    lint-commits)
+        shift
+        lint_commits "$@"
+        ;;
     *)
         msg_red "xbps-src: invalid target $XBPS_TARGET.\n"
         usage && exit 1

From 5e6931f4303c2c40e28ab2839876c217c496858b 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: Mon, 17 May 2021 22:21:09 +0700
Subject: [PATCH 2/2] workflows: enable lint-commits

---
 .github/workflows/build.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..2da230588b1c 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,7 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      - run: ./xbps-src lint-commits FETCH_HEAD
 
   # Build changed packages.
   build:

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
@ 2021-05-17 15:27 ` sgn
  2021-05-17 15:28 ` [PR REVIEW] " ericonr
                   ` (20 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:27 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 3405 bytes --]

From 9207161ed843da905c593aaa09484e106792fc6a 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH 1/2] shutils: add basic commit lint

Warn if:
* subject is longer than 50 characters
Error if:
* any lines are longer than 80 characters
* second line is not blank
---
 common/xbps-src/shutils/lint_commits.sh | 39 +++++++++++++++++++++++++
 xbps-src                                |  9 ++++++
 2 files changed, 48 insertions(+)
 create mode 100755 common/xbps-src/shutils/lint_commits.sh

diff --git a/common/xbps-src/shutils/lint_commits.sh b/common/xbps-src/shutils/lint_commits.sh
new file mode 100755
index 000000000000..9e5ec3a57ffd
--- /dev/null
+++ b/common/xbps-src/shutils/lint_commits.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+lint_commits() {
+	local base="$1"
+	local status=0
+	local cmt
+	if [ -n "$base" ]; then
+		base=$("$XBPS_GIT_CMD" rev-parse --verify "$base") ||
+			return
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify FETCH_HEAD 2>/dev/null); then
+		:
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify ORIG_HEAD 2>/dev/null); then
+		:
+	else
+		echo base commit not found >&2
+		exit 1
+	fi
+
+	for cmt in $("$XBPS_GIT_CMD" rev-list --reverse --abbrev-commit "$base"..HEAD)
+	do
+		"$XBPS_GIT_CMD" cat-file commit "$cmt" |
+		awk -vC="$cmt" '
+		/^$/ && !msg { msg = 1; next }
+		!msg { next }
+		!/ / && (length > 80) { print C ": long line: " $0; exit 1 }
+		!subject {
+			if (length > 50) { print C ": subject is a bit long" }
+			# Below check is too noisy?
+			# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+			#	print C ": not new package/update/removal?"
+			# }
+			subject = 1; next
+		}
+		/^$/ { body = 1; next }
+		!body { print C ": second line must be blank"; exit 1 }
+		' || status=1
+	done
+	return $status
+}
diff --git a/xbps-src b/xbps-src
index c3cd7e5db10b..798ec418769d 100755
--- a/xbps-src
+++ b/xbps-src
@@ -141,6 +141,10 @@ update-hash-cache
 zap
     Removes a masterdir but preserving ccache, distcc and host directories.
 
+lint-commits [base-commit]
+    Do basic check on commit made from [base-commit] exclusively.
+    If [base-commit] omited, FETCH_HEAD or ORIG_HEAD will be used.
+
 Options:
 
 -1  If dependencies of target package are missing, fail instead of building them.
@@ -964,6 +968,11 @@ case "$XBPS_TARGET" in
     zap)
         masterdir_zap
         ;;
+    lint-commits)
+        shift
+        read_pkg ignore-problems
+        lint_commits "$@"
+        ;;
     *)
         msg_red "xbps-src: invalid target $XBPS_TARGET.\n"
         usage && exit 1

From 8e20fc14955c536c0f040a82ad018bfae0cb75bd 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: Mon, 17 May 2021 22:21:09 +0700
Subject: [PATCH 2/2] workflows: enable lint-commits

---
 .github/workflows/build.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..2da230588b1c 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,7 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      - run: ./xbps-src lint-commits FETCH_HEAD
 
   # Build changed packages.
   build:

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
  2021-05-17 15:27 ` [PR PATCH] [Updated] " sgn
@ 2021-05-17 15:28 ` ericonr
  2021-05-17 15:28 ` ericonr
                   ` (19 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2021-05-17 15:28 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r633632348

Comment:
Use `msg_error`? (is it available here?)

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
  2021-05-17 15:27 ` [PR PATCH] [Updated] " sgn
  2021-05-17 15:28 ` [PR REVIEW] " ericonr
@ 2021-05-17 15:28 ` ericonr
  2021-05-17 15:28 ` ericonr
                   ` (18 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2021-05-17 15:28 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r633634280

Comment:
I think it could take a second optional argument to override `HEAD` here, what do you think? Otherwise it will be harder to run locally.

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (2 preceding siblings ...)
  2021-05-17 15:28 ` ericonr
@ 2021-05-17 15:28 ` ericonr
  2021-05-17 15:29 ` ericonr
                   ` (17 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2021-05-17 15:28 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r633633324

Comment:
It would be noisy for test fixes and xbps-src changes, not sure it's worth it but I don't think it'd be that noisy either.

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

* Re: lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (3 preceding siblings ...)
  2021-05-17 15:28 ` ericonr
@ 2021-05-17 15:29 ` ericonr
  2021-05-17 15:32 ` [PR PATCH] [Updated] " sgn
                   ` (16 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: ericonr @ 2021-05-17 15:29 UTC (permalink / raw)
  To: ml

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

New comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#issuecomment-842419326

Comment:
```
Run ./xbps-src lint-commits FETCH_HEAD
./xbps-src: line 354: xbps-uhelper: command not found
./xbps-src: line 358: xbps-uhelper: command not found
xbps-install is missing in your system, can't continue!
xbps-query is missing in your system, can't continue!
xbps-rindex is missing in your system, can't continue!
xbps-uhelper is missing in your system, can't continue!
xbps-reconfigure is missing in your system, can't continue!
xbps-remove is missing in your system, can't continue!
xbps-create is missing in your system, can't continue!
xbps-uchroot is missing in your system, can't continue!
xbps-uunshare is missing in your system, can't continue!
Error: Process completed with exit code 1.
```

maybe make it a CI helper instead?

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (4 preceding siblings ...)
  2021-05-17 15:29 ` ericonr
@ 2021-05-17 15:32 ` sgn
  2021-05-17 15:33 ` [PR REVIEW] " sgn
                   ` (15 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:32 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 3370 bytes --]

From 79ef4d7c6224c2390b6e5952cae02d31b6b201e7 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH 1/2] shutils: add basic commit lint

Warn if:
* subject is longer than 50 characters
Error if:
* any lines are longer than 80 characters
* second line is not blank
---
 common/xbps-src/shutils/lint_commits.sh | 39 +++++++++++++++++++++++++
 xbps-src                                |  8 +++++
 2 files changed, 47 insertions(+)
 create mode 100755 common/xbps-src/shutils/lint_commits.sh

diff --git a/common/xbps-src/shutils/lint_commits.sh b/common/xbps-src/shutils/lint_commits.sh
new file mode 100755
index 000000000000..9e5ec3a57ffd
--- /dev/null
+++ b/common/xbps-src/shutils/lint_commits.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+lint_commits() {
+	local base="$1"
+	local status=0
+	local cmt
+	if [ -n "$base" ]; then
+		base=$("$XBPS_GIT_CMD" rev-parse --verify "$base") ||
+			return
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify FETCH_HEAD 2>/dev/null); then
+		:
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify ORIG_HEAD 2>/dev/null); then
+		:
+	else
+		echo base commit not found >&2
+		exit 1
+	fi
+
+	for cmt in $("$XBPS_GIT_CMD" rev-list --reverse --abbrev-commit "$base"..HEAD)
+	do
+		"$XBPS_GIT_CMD" cat-file commit "$cmt" |
+		awk -vC="$cmt" '
+		/^$/ && !msg { msg = 1; next }
+		!msg { next }
+		!/ / && (length > 80) { print C ": long line: " $0; exit 1 }
+		!subject {
+			if (length > 50) { print C ": subject is a bit long" }
+			# Below check is too noisy?
+			# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+			#	print C ": not new package/update/removal?"
+			# }
+			subject = 1; next
+		}
+		/^$/ { body = 1; next }
+		!body { print C ": second line must be blank"; exit 1 }
+		' || status=1
+	done
+	return $status
+}
diff --git a/xbps-src b/xbps-src
index c3cd7e5db10b..c5dbac6a90b3 100755
--- a/xbps-src
+++ b/xbps-src
@@ -141,6 +141,10 @@ update-hash-cache
 zap
     Removes a masterdir but preserving ccache, distcc and host directories.
 
+lint-commits [base-commit]
+    Do basic check on commit made from [base-commit] exclusively.
+    If [base-commit] omited, FETCH_HEAD or ORIG_HEAD will be used.
+
 Options:
 
 -1  If dependencies of target package are missing, fail instead of building them.
@@ -964,6 +968,10 @@ case "$XBPS_TARGET" in
     zap)
         masterdir_zap
         ;;
+    lint-commits)
+        shift
+        lint_commits "$@"
+        ;;
     *)
         msg_red "xbps-src: invalid target $XBPS_TARGET.\n"
         usage && exit 1

From 40474996be3ab1172c458b7b947a4a7253e0acf3 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: Mon, 17 May 2021 22:21:09 +0700
Subject: [PATCH 2/2] workflows: enable lint-commits

---
 .github/workflows/build.yaml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..2da230588b1c 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,7 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      - run: ./xbps-src lint-commits FETCH_HEAD
 
   # Build changed packages.
   build:

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (5 preceding siblings ...)
  2021-05-17 15:32 ` [PR PATCH] [Updated] " sgn
@ 2021-05-17 15:33 ` sgn
  2021-05-17 15:37 ` sgn
                   ` (14 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:33 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r633639131

Comment:
I haven't checked. However, as of it's now, it can't be run in Ubuntu since `xbps-src` needs to check for `xbps-*`.
I'm not sure if it's worth to be put inside `xbps-src`.

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

* Re: lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (6 preceding siblings ...)
  2021-05-17 15:33 ` [PR REVIEW] " sgn
@ 2021-05-17 15:37 ` sgn
  2021-05-17 15:37 ` sgn
                   ` (13 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:37 UTC (permalink / raw)
  To: ml

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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#issuecomment-842425491

Comment:
> ```
> Run ./xbps-src lint-commits FETCH_HEAD
> ./xbps-src: line 354: xbps-uhelper: command not found
> ./xbps-src: line 358: xbps-uhelper: command not found
> xbps-install is missing in your system, can't continue!
> xbps-query is missing in your system, can't continue!
> xbps-rindex is missing in your system, can't continue!
> xbps-uhelper is missing in your system, can't continue!
> xbps-reconfigure is missing in your system, can't continue!
> xbps-remove is missing in your system, can't continue!
> xbps-create is missing in your system, can't continue!
> xbps-uchroot is missing in your system, can't continue!
> xbps-uunshare is missing in your system, can't continue!
> Error: Process completed with exit code 1.
> ```
> 
> maybe make it a CI helper instead?

CI helper would make it hard for other people to run locally, which is my ultimate goal.
I'm thinking about `ln -sf /bin/true /some/where/in/path/xbps-<something>` instead :-p

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

* Re: lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (7 preceding siblings ...)
  2021-05-17 15:37 ` sgn
@ 2021-05-17 15:37 ` sgn
  2021-05-17 15:42 ` [PR PATCH] [Updated] " sgn
                   ` (12 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:37 UTC (permalink / raw)
  To: ml

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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#issuecomment-842425491

Comment:
> ```
> Run ./xbps-src lint-commits FETCH_HEAD
> ./xbps-src: line 354: xbps-uhelper: command not found
> ./xbps-src: line 358: xbps-uhelper: command not found
> xbps-install is missing in your system, can't continue!
> xbps-query is missing in your system, can't continue!
> xbps-rindex is missing in your system, can't continue!
> xbps-uhelper is missing in your system, can't continue!
> xbps-reconfigure is missing in your system, can't continue!
> xbps-remove is missing in your system, can't continue!
> xbps-create is missing in your system, can't continue!
> xbps-uchroot is missing in your system, can't continue!
> xbps-uunshare is missing in your system, can't continue!
> Error: Process completed with exit code 1.
> ```
> 
> maybe make it a CI helper instead?

CI helper would make it hard for other people to run locally, which is my ultimate goal.
I'm thinking about `ln -sf /bin/true /some/where/in/path/xbps-<something>` in workflows instead :-p

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (8 preceding siblings ...)
  2021-05-17 15:37 ` sgn
@ 2021-05-17 15:42 ` sgn
  2021-05-17 16:31 ` Duncaen
                   ` (11 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-17 15:42 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 4021 bytes --]

From 79ef4d7c6224c2390b6e5952cae02d31b6b201e7 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH 1/2] shutils: add basic commit lint

Warn if:
* subject is longer than 50 characters
Error if:
* any lines are longer than 80 characters
* second line is not blank
---
 common/xbps-src/shutils/lint_commits.sh | 39 +++++++++++++++++++++++++
 xbps-src                                |  8 +++++
 2 files changed, 47 insertions(+)
 create mode 100755 common/xbps-src/shutils/lint_commits.sh

diff --git a/common/xbps-src/shutils/lint_commits.sh b/common/xbps-src/shutils/lint_commits.sh
new file mode 100755
index 000000000000..9e5ec3a57ffd
--- /dev/null
+++ b/common/xbps-src/shutils/lint_commits.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+lint_commits() {
+	local base="$1"
+	local status=0
+	local cmt
+	if [ -n "$base" ]; then
+		base=$("$XBPS_GIT_CMD" rev-parse --verify "$base") ||
+			return
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify FETCH_HEAD 2>/dev/null); then
+		:
+	elif base=$("$XBPS_GIT_CMD" rev-parse --verify ORIG_HEAD 2>/dev/null); then
+		:
+	else
+		echo base commit not found >&2
+		exit 1
+	fi
+
+	for cmt in $("$XBPS_GIT_CMD" rev-list --reverse --abbrev-commit "$base"..HEAD)
+	do
+		"$XBPS_GIT_CMD" cat-file commit "$cmt" |
+		awk -vC="$cmt" '
+		/^$/ && !msg { msg = 1; next }
+		!msg { next }
+		!/ / && (length > 80) { print C ": long line: " $0; exit 1 }
+		!subject {
+			if (length > 50) { print C ": subject is a bit long" }
+			# Below check is too noisy?
+			# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+			#	print C ": not new package/update/removal?"
+			# }
+			subject = 1; next
+		}
+		/^$/ { body = 1; next }
+		!body { print C ": second line must be blank"; exit 1 }
+		' || status=1
+	done
+	return $status
+}
diff --git a/xbps-src b/xbps-src
index c3cd7e5db10b..c5dbac6a90b3 100755
--- a/xbps-src
+++ b/xbps-src
@@ -141,6 +141,10 @@ update-hash-cache
 zap
     Removes a masterdir but preserving ccache, distcc and host directories.
 
+lint-commits [base-commit]
+    Do basic check on commit made from [base-commit] exclusively.
+    If [base-commit] omited, FETCH_HEAD or ORIG_HEAD will be used.
+
 Options:
 
 -1  If dependencies of target package are missing, fail instead of building them.
@@ -964,6 +968,10 @@ case "$XBPS_TARGET" in
     zap)
         masterdir_zap
         ;;
+    lint-commits)
+        shift
+        lint_commits "$@"
+        ;;
     *)
         msg_red "xbps-src: invalid target $XBPS_TARGET.\n"
         usage && exit 1

From 47f6e987b2dc187f6985f0888af84f5ef1396ae4 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: Mon, 17 May 2021 22:21:09 +0700
Subject: [PATCH 2/2] workflows: enable lint-commits

---
 .github/workflows/build.yaml |  1 +
 common/travis/xcommitlint.sh | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
 create mode 100755 common/travis/xcommitlint.sh

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..78aae5cb2f9e 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,7 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      - run: common/travis/xcommitlint.sh
 
   # Build changed packages.
   build:
diff --git a/common/travis/xcommitlint.sh b/common/travis/xcommitlint.sh
new file mode 100755
index 000000000000..4da7d3070e7a
--- /dev/null
+++ b/common/travis/xcommitlint.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Copied from xbps-src
+readonly REQHOST_UTILS="xbps-install xbps-query xbps-rindex xbps-uhelper
+    xbps-reconfigure xbps-remove xbps-create xbps-uchroot xbps-uunshare"
+
+PATH=$PATH:/tmp/fake-xbps
+mkdir -p /tmp/fake-xbps
+
+for req in $REQHOST_UTILS
+do
+	ln -sf /bin/true /tmp/fake-xbps/$req
+done
+
+exec ./xbps-src lint-commits FETCH_HEAD

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

* Re: lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (9 preceding siblings ...)
  2021-05-17 15:42 ` [PR PATCH] [Updated] " sgn
@ 2021-05-17 16:31 ` Duncaen
  2021-05-18  5:23 ` sgn
                   ` (10 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: Duncaen @ 2021-05-17 16:31 UTC (permalink / raw)
  To: ml

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

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#issuecomment-842465746

Comment:
I would probably prefer if its not part of xbps-src itself. Maybe a scripts or contrib directory?

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

* Re: lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (10 preceding siblings ...)
  2021-05-17 16:31 ` Duncaen
@ 2021-05-18  5:23 ` sgn
  2021-05-18 16:11 ` [PR PATCH] [Updated] " sgn
                   ` (9 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-18  5:23 UTC (permalink / raw)
  To: ml

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

New comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#issuecomment-842849408

Comment:
> I would probably prefer if its not part of xbps-src itself. Maybe a scripts or contrib directory?

Yeah, being part of xbps-src itself increases the startup time and requires a workaround for CI.

I'm not sure which actions should be chosen. I want to make it visible and obvious to users but not pollute top level directory.
So, somewhere in common/scripts and documented in Manual.md?

Can we just assume that such scripts always be run in top level directory, for simplicity sake?

In a long run, I think we're better to move xlint there, too? And factor out update-check?

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (11 preceding siblings ...)
  2021-05-18  5:23 ` sgn
@ 2021-05-18 16:11 ` sgn
  2021-05-18 16:12 ` [PR REVIEW] " sgn
                   ` (8 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-18 16:11 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 2457 bytes --]

From 03fa20ddb2d1202ed876d8199ced19395ec70a19 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH] shutils: add basic commit lint

Warn if:
* subject is longer than 50 characters

Error if:
* any lines are longer than 80 characters except it's footnotes
* second line is not blank
---
 .github/workflows/build.yaml |  1 +
 common/scripts/lint-commits  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100755 common/scripts/lint-commits

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..011cda3b3ed1 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,7 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      - run: common/scripts/lint-commits
 
   # Build changed packages.
   build:
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
new file mode 100755
index 000000000000..1c5d6934a972
--- /dev/null
+++ b/common/scripts/lint-commits
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+die () {
+	printf '%s\n' "$*" >&2
+	exit 1
+}
+
+GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
+GIT_CMD=$(command -v git 2>/dev/null) ||
+die "chroot-git and git couldn't be found"
+
+rev_parse () {
+	if [ -n "$1" ]; then
+		"$GIT_CMD" rev-parse --verify "$1"
+	else
+		shift
+		while test "$#" != 0
+		do
+			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			shift
+		done
+		return 1
+	fi
+}
+
+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 --reverse --abbrev-commit $base..$tip)
+do
+	"$GIT_CMD" cat-file commit "$cmt" |
+	awk -vC="$cmt" '
+	# skip header
+	/^$/ && !msg { msg = 1; next }
+	!msg { next }
+	# 3: long-line-is-banned-except-footnote-like-this
+	(NF > 2) && (length > 80) { print C ": long line: " $0; exit 1 }
+	!subject {
+		if (length > 50) { print C ": subject is a bit long" }
+		# Below check is too noisy?
+		# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+		#	print C ": not new package/update/removal?"
+		# }
+		subject = 1; next
+	}
+	/^$/ { body = 1; next }
+	!body { print C ": second line must be blank"; exit 1 }
+	' || status=1
+done
+exit $status

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (12 preceding siblings ...)
  2021-05-18 16:11 ` [PR PATCH] [Updated] " sgn
@ 2021-05-18 16:12 ` sgn
  2021-05-18 16:12 ` sgn
                   ` (7 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-18 16:12 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r634536494

Comment:
I think we should discuss that later. I really want to have some lint for blank line and long lines soon.

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (13 preceding siblings ...)
  2021-05-18 16:12 ` [PR REVIEW] " sgn
@ 2021-05-18 16:12 ` sgn
  2021-05-19  0:44 ` [PR PATCH] [Updated] " sgn
                   ` (6 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-18 16:12 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r634536816

Comment:
Implemented.

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (14 preceding siblings ...)
  2021-05-18 16:12 ` sgn
@ 2021-05-19  0:44 ` sgn
  2021-05-19  0:56 ` sgn
                   ` (5 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-19  0:44 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 2453 bytes --]

From 647ffcdfce88d5314715e60cad5f205819fa2538 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH] common: add basic commit lint

Warn if:
* subject is longer than 50 characters

Error if:
* any lines are longer than 80 characters except it's footnotes
* second line is not blank
---
 .github/workflows/build.yaml |  1 +
 common/scripts/lint-commits  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+)
 create mode 100755 common/scripts/lint-commits

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..011cda3b3ed1 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,7 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      - run: common/scripts/lint-commits
 
   # Build changed packages.
   build:
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
new file mode 100755
index 000000000000..64d96187db89
--- /dev/null
+++ b/common/scripts/lint-commits
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+die() {
+	printf '%s\n' "$*" >&2
+	exit 1
+}
+
+GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
+GIT_CMD=$(command -v git 2>/dev/null) ||
+die "chroot-git and git couldn't be found"
+
+rev_parse() {
+	if [ -n "$1" ]; then
+		"$GIT_CMD" rev-parse --verify "$1"
+	else
+		shift
+		while test "$#" != 0
+		do
+			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			shift
+		done
+		return 1
+	fi
+}
+
+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)
+do
+	"$GIT_CMD" cat-file commit "$cmt" |
+	awk -vC="$cmt" '
+	# skip header
+	/^$/ && !msg { msg = 1; next }
+	!msg { next }
+	# 3: long-line-is-banned-except-footnote-like-this-for-url
+	(NF > 2) && (length > 80) { print C ": long line: " $0; exit 1 }
+	!subject {
+		if (length > 50) { print C ": subject is a bit long" }
+		# Below check is too noisy?
+		# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+		# 	print C ": not new package/update/removal?"
+		# }
+		subject = 1; next
+	}
+	/^$/ { body = 1; next }
+	!body { print C ": second line must be blank"; exit 1 }
+	' || status=1
+done
+exit $status

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (15 preceding siblings ...)
  2021-05-19  0:44 ` [PR PATCH] [Updated] " sgn
@ 2021-05-19  0:56 ` sgn
  2021-05-19 16:15 ` [PR REVIEW] " paper42
                   ` (4 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-19  0:56 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 2528 bytes --]

From 2080f7a636ba9eed20871dfa2d6735e59d76cb0f 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH] common: add basic commit lint

Warn if:
* subject is longer than 50 characters

Error if:
* any lines are longer than 80 characters except it's footnotes
* second line is not blank
---
 .github/workflows/build.yaml |  2 ++
 common/scripts/lint-commits  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100755 common/scripts/lint-commits

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..eb96a151c599 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,8 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      # GitHub Action create a merge commit, ignore it
+      - run: common/scripts/lint-commits FETCH_HEAD HEAD^2
 
   # Build changed packages.
   build:
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
new file mode 100755
index 000000000000..64d96187db89
--- /dev/null
+++ b/common/scripts/lint-commits
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+die() {
+	printf '%s\n' "$*" >&2
+	exit 1
+}
+
+GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
+GIT_CMD=$(command -v git 2>/dev/null) ||
+die "chroot-git and git couldn't be found"
+
+rev_parse() {
+	if [ -n "$1" ]; then
+		"$GIT_CMD" rev-parse --verify "$1"
+	else
+		shift
+		while test "$#" != 0
+		do
+			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			shift
+		done
+		return 1
+	fi
+}
+
+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)
+do
+	"$GIT_CMD" cat-file commit "$cmt" |
+	awk -vC="$cmt" '
+	# skip header
+	/^$/ && !msg { msg = 1; next }
+	!msg { next }
+	# 3: long-line-is-banned-except-footnote-like-this-for-url
+	(NF > 2) && (length > 80) { print C ": long line: " $0; exit 1 }
+	!subject {
+		if (length > 50) { print C ": subject is a bit long" }
+		# Below check is too noisy?
+		# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+		# 	print C ": not new package/update/removal?"
+		# }
+		subject = 1; next
+	}
+	/^$/ { body = 1; next }
+	!body { print C ": second line must be blank"; exit 1 }
+	' || status=1
+done
+exit $status

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (16 preceding siblings ...)
  2021-05-19  0:56 ` sgn
@ 2021-05-19 16:15 ` paper42
  2021-05-20  0:48 ` sgn
                   ` (3 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: paper42 @ 2021-05-19 16:15 UTC (permalink / raw)
  To: ml

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

New review comment by paper42 on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r635393391

Comment:
shouldn't it say `or` instead of `and`?

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

* Re: [PR REVIEW] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (17 preceding siblings ...)
  2021-05-19 16:15 ` [PR REVIEW] " paper42
@ 2021-05-20  0:48 ` sgn
  2021-05-20  0:50 ` [PR PATCH] [Updated] " sgn
                   ` (2 subsequent siblings)
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-20  0:48 UTC (permalink / raw)
  To: ml

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

New review comment by sgn on void-packages repository

https://github.com/void-linux/void-packages/pull/30950#discussion_r635672888

Comment:
Being a non-native Indo-European speaker, I don't know. I guess it's better to say "need either chroot-git or git"?

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (18 preceding siblings ...)
  2021-05-20  0:48 ` sgn
@ 2021-05-20  0:50 ` sgn
  2021-05-20 16:33 ` sgn
  2021-05-21  8:56 ` [PR PATCH] [Merged]: " sgn
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-20  0:50 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 2545 bytes --]

From fefa3e01e3fbaa847fa9417191dba45fab894050 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH] common: add basic commit lint

Warn if:
* subject is longer than 50 characters

Error if:
* any lines are longer than 80 characters except it's footnotes
* second line is not blank
---
 .github/workflows/build.yaml |  2 ++
 common/scripts/lint-commits  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100755 common/scripts/lint-commits

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..eb96a151c599 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,8 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      # GitHub Action create a merge commit, ignore it
+      - run: common/scripts/lint-commits FETCH_HEAD HEAD^2
 
   # Build changed packages.
   build:
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
new file mode 100755
index 000000000000..e6eaa8b9f97b
--- /dev/null
+++ b/common/scripts/lint-commits
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+die() {
+	printf '%s\n' "$*" >&2
+	exit 1
+}
+
+GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
+GIT_CMD=$(command -v git 2>/dev/null) ||
+die "need either chroot-git or git but couldn't found any!"
+
+rev_parse() {
+	if [ -n "$1" ]; then
+		"$GIT_CMD" rev-parse --verify "$1"
+	else
+		shift
+		while test "$#" != 0
+		do
+			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			shift
+		done
+		return 1
+	fi
+}
+
+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)
+do
+	"$GIT_CMD" cat-file commit "$cmt" |
+	awk -vC="$cmt" '
+	# skip header
+	/^$/ && !msg { msg = 1; next }
+	!msg { next }
+	# 3: long-line-is-banned-except-footnote-like-this-for-url
+	(NF > 2) && (length > 80) { print C ": long line: " $0; exit 1 }
+	!subject {
+		if (length > 50) { print C ": subject is a bit long" }
+		# Below check is too noisy?
+		# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+		# 	print C ": not new package/update/removal?"
+		# }
+		subject = 1; next
+	}
+	/^$/ { body = 1; next }
+	!body { print C ": second line must be blank"; exit 1 }
+	' || status=1
+done
+exit $status

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

* Re: [PR PATCH] [Updated] lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (19 preceding siblings ...)
  2021-05-20  0:50 ` [PR PATCH] [Updated] " sgn
@ 2021-05-20 16:33 ` sgn
  2021-05-21  8:56 ` [PR PATCH] [Merged]: " sgn
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-20 16:33 UTC (permalink / raw)
  To: ml

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

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

https://github.com/sgn/void-packages lint-commits
https://github.com/void-linux/void-packages/pull/30950

lint commits's message
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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/30950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-lint-commits-30950.patch --]
[-- Type: text/x-diff, Size: 2534 bytes --]

From 1b994a1478c145191813103a051852eec10f4610 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: Mon, 17 May 2021 22:10:52 +0700
Subject: [PATCH] common: add basic commit lint

Warn if:
* subject is longer than 50 characters

Error if:
* any lines are longer than 80 characters except it's footnotes
* second line is not blank
---
 .github/workflows/build.yaml |  2 ++
 common/scripts/lint-commits  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100755 common/scripts/lint-commits

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 1ea1da2e4881..eb96a151c599 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -21,6 +21,8 @@ jobs:
       - run: common/travis/changed_templates.sh
       - run: common/travis/fetch-xtools.sh
       - run: common/travis/xlint.sh
+      # GitHub Action create a merge commit, ignore it
+      - run: common/scripts/lint-commits FETCH_HEAD HEAD^2
 
   # Build changed packages.
   build:
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
new file mode 100755
index 000000000000..785bf0ef1d0d
--- /dev/null
+++ b/common/scripts/lint-commits
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+die() {
+	printf '%s\n' "$*" >&2
+	exit 1
+}
+
+GIT_CMD=$(command -v chroot-git 2>/dev/null) ||
+GIT_CMD=$(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"
+	else
+		shift
+		while test "$#" != 0
+		do
+			"$GIT_CMD" rev-parse --verify "$1" 2>/dev/null && return
+			shift
+		done
+		return 1
+	fi
+}
+
+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)
+do
+	"$GIT_CMD" cat-file commit "$cmt" |
+	awk -vC="$cmt" '
+	# skip header
+	/^$/ && !msg { msg = 1; next }
+	!msg { next }
+	# 3: long-line-is-banned-except-footnote-like-this-for-url
+	(NF > 2) && (length > 80) { print C ": long line: " $0; exit 1 }
+	!subject {
+		if (length > 50) { print C ": subject is a bit long" }
+		# Below check is too noisy?
+		# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
+		# 	print C ": not new package/update/removal?"
+		# }
+		subject = 1; next
+	}
+	/^$/ { body = 1; next }
+	!body { print C ": second line must be blank"; exit 1 }
+	' || status=1
+done
+exit $status

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

* Re: [PR PATCH] [Merged]: lint commits's message
  2021-05-17 15:22 [PR PATCH] lint commits's message sgn
                   ` (20 preceding siblings ...)
  2021-05-20 16:33 ` sgn
@ 2021-05-21  8:56 ` sgn
  21 siblings, 0 replies; 23+ messages in thread
From: sgn @ 2021-05-21  8:56 UTC (permalink / raw)
  To: ml

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

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

lint commits's message
https://github.com/void-linux/void-packages/pull/30950

Description:
<!-- Mark items with [x] where applicable -->

#### General
- [ ] This is a new package and it conforms to the [quality requirements](https://github.com/void-linux/void-packages/blob/master/Manual.md#quality-requirements)

#### Have the results of the proposed changes been tested?
- [ ] I use the packages affected by the proposed changes on a regular basis and confirm this PR works for me
- [ ] I generally don't use the affected packages but briefly tested this PR

<!--
If GitHub CI cannot be used to validate the build result (for example, if the
build is likely to take several hours), make sure to
[skip CI](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration).
When skipping CI, uncomment and fill out the following section.
Note: for builds that are likely to complete in less than 2 hours, it is not
acceptable to skip CI.
-->
<!-- 
#### Does it build and run successfully? 
(Please choose at least one native build and, if supported, at least one cross build. More are better.)
- [ ] 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] 23+ messages in thread

end of thread, other threads:[~2021-05-21  8:56 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 15:22 [PR PATCH] lint commits's message sgn
2021-05-17 15:27 ` [PR PATCH] [Updated] " sgn
2021-05-17 15:28 ` [PR REVIEW] " ericonr
2021-05-17 15:28 ` ericonr
2021-05-17 15:28 ` ericonr
2021-05-17 15:29 ` ericonr
2021-05-17 15:32 ` [PR PATCH] [Updated] " sgn
2021-05-17 15:33 ` [PR REVIEW] " sgn
2021-05-17 15:37 ` sgn
2021-05-17 15:37 ` sgn
2021-05-17 15:42 ` [PR PATCH] [Updated] " sgn
2021-05-17 16:31 ` Duncaen
2021-05-18  5:23 ` sgn
2021-05-18 16:11 ` [PR PATCH] [Updated] " sgn
2021-05-18 16:12 ` [PR REVIEW] " sgn
2021-05-18 16:12 ` sgn
2021-05-19  0:44 ` [PR PATCH] [Updated] " sgn
2021-05-19  0:56 ` sgn
2021-05-19 16:15 ` [PR REVIEW] " paper42
2021-05-20  0:48 ` sgn
2021-05-20  0:50 ` [PR PATCH] [Updated] " sgn
2021-05-20 16:33 ` sgn
2021-05-21  8:56 ` [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).