From ab4a651d04f2356764955d195441ec174c6ee95a Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 16 Sep 2022 00:55:07 -0400 Subject: [PATCH 1/5] .github/workflows: simplify logic to find git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From chroot-git 2.33.1, we always have an executable named git for other build infrastructure and lints. Let's remove the shenanigans 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. Co-authored-by: Đoàn Trần Công Danh --- .github/workflows/build.yaml | 4 ++-- .github/workflows/cycles.yml | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ce995e2d9c79..95f1cd88e338 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,7 +21,7 @@ jobs: runs-on: ubuntu-latest env: - PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' + PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' XLINT: '1' LICENSE_LIST: common/travis/license.lst @@ -44,7 +44,7 @@ jobs: container: image: 'ghcr.io/void-linux/xbps-src-masterdir:20220527RC01-${{ matrix.config.bootstrap }}' env: - PATH: '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' + PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' ARCH: '${{ matrix.config.arch }}' BOOTSTRAP: '${{ matrix.config.bootstrap }}' TEST: '${{ matrix.config.test }}' diff --git a/.github/workflows/cycles.yml b/.github/workflows/cycles.yml index 3f85ac6fa74a..1c7ba22b354a 100644 --- a/.github/workflows/cycles.yml +++ b/.github/workflows/cycles.yml @@ -11,6 +11,8 @@ jobs: issues: write container: image: 'ghcr.io/void-linux/xbps-src-masterdir:20220527RC01-x86_64-musl' + env: + PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin' steps: - name: Prepare container run: | @@ -33,13 +35,8 @@ 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 # 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 From f8b09f40122bf0e9722926e7b82a6d845b547a4b Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 16 Sep 2022 00:59:15 -0400 Subject: [PATCH 2/5] common: simplify logic to find git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From chroot-git 2.33.1, we always have an executable named git for other build infrastructure and lints. Let's remove the shenanigans 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. Co-authored-by: Đoàn Trần Công Danh --- common/scripts/lint-commits | 11 +++++------ common/scripts/lint-version-change | 11 +++-------- common/travis/changed_templates.sh | 12 +++--------- common/travis/fetch_upstream.sh | 10 ++-------- 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits index 7207ed81d5aa..88e6b1f959ae 100755 --- a/common/scripts/lint-commits +++ b/common/scripts/lint-commits @@ -5,18 +5,17 @@ die() { exit 1 } -GIT_CMD=$(command -v chroot-git 2>/dev/null) || -GIT_CMD=$(command -v git 2>/dev/null) || +command -v git 2>/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 +26,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..1dc0072f67ea 100755 --- a/common/scripts/lint-version-change +++ b/common/scripts/lint-version-change @@ -13,20 +13,15 @@ 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 +command -v git 2>/dev/null 2>&1 || die "neither chroot-git nor git could be found" -fi scan() { rx="$1" msg="$2" template_path=$template 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 +32,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..68323ab8c470 100755 --- a/common/travis/changed_templates.sh +++ b/common/travis/changed_templates.sh @@ -2,19 +2,13 @@ # # 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 - -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 +17,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..e5ec5979493b 100755 --- a/common/travis/fetch_upstream.sh +++ b/common/travis/fetch_upstream.sh @@ -2,14 +2,8 @@ # # 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 - # 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 6d91b31d003e977c2954a548443c050d07a11020 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 16 Sep 2022 01:01:25 -0400 Subject: [PATCH 3/5] .github/workflows: update actions/checkout to v3 this removes the need for manually setting `safe.directory` in the git config because the action sets it for us by default --- .github/workflows/build.yaml | 6 ++++-- .github/workflows/cycles.yml | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 95f1cd88e338..ae75bea55937 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,7 +26,8 @@ jobs: LICENSE_LIST: common/travis/license.lst steps: - - uses: actions/checkout@v1 + - run: mkdir -p /usr/local/bin && echo '#!/bin/sh' > /usr/local/bin/git-submodule + - uses: actions/checkout@v3 with: fetch-depth: 200 - run: common/travis/fetch_upstream.sh @@ -73,7 +74,8 @@ jobs: # Upgrade again (in case there was a xbps update) xbps-install -yu - - uses: actions/checkout@v1 + - run: mkdir -p /usr/local/bin && echo '#!/bin/sh' > /usr/local/bin/git-submodule + - uses: actions/checkout@v3 with: fetch-depth: 200 - name: Create hostrepo and prepare masterdir diff --git a/.github/workflows/cycles.yml b/.github/workflows/cycles.yml index 1c7ba22b354a..c51c30b9eae6 100644 --- a/.github/workflows/cycles.yml +++ b/.github/workflows/cycles.yml @@ -25,7 +25,8 @@ jobs: xbps-install -yu # Install script dependencies xbps-install -y python3-networkx github-cli - - uses: actions/checkout@v1 + - run: mkdir -p /usr/local/bin && echo '#!/bin/sh' > /usr/local/bin/git-submodule + - uses: actions/checkout@v3 with: fetch-depth: 1 - name: Create hostrepo and prepare masterdir @@ -35,8 +36,6 @@ jobs: common/travis/prepare.sh - name: Find cycles and open issues run: | - # required by git 2.35.2+ - 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 From 39ff192004fa41b2e6b8bf85ad0112315fbb1557 Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 16 Sep 2022 01:02:32 -0400 Subject: [PATCH 4/5] common/travis/fetch_upstream.sh: remove manual git config safe.directory no longer necessary with actions/checkout@v3 --- common/travis/fetch_upstream.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/travis/fetch_upstream.sh b/common/travis/fetch_upstream.sh index e5ec5979493b..f03aee6a0d4c 100755 --- a/common/travis/fetch_upstream.sh +++ b/common/travis/fetch_upstream.sh @@ -2,8 +2,5 @@ # # changed_templates.sh -# required by git 2.35.2+ -git config --global --add safe.directory "$PWD" - /bin/echo -e '\x1b[32mFetching upstream...\x1b[0m' git fetch --depth 200 https://github.com/void-linux/void-packages.git master From 13929beb6039d9b1897de20c9ab3e1aa8913faed Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Fri, 16 Sep 2022 01:03:20 -0400 Subject: [PATCH 5/5] chezmoi: TEMP TEST --- srcpkgs/chezmoi/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/srcpkgs/chezmoi/template b/srcpkgs/chezmoi/template index 13505278dbaa..b333e8945f7e 100644 --- a/srcpkgs/chezmoi/template +++ b/srcpkgs/chezmoi/template @@ -1,7 +1,7 @@ # Template file for 'chezmoi' pkgname=chezmoi version=2.22.1 -revision=1 +revision=2 build_style=go go_import_path="github.com/twpayne/chezmoi/v2" go_build_tags="noembeddocs noupgrade"