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 748782ad9fef32266c41864881d86b5e777ca6d9 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 | 11 +++-------- 4 files changed, 14 insertions(+), 31 deletions(-) diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits index 7207ed81d5aa..5f465667cf8e 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 >/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 +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..157daf681019 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 >/dev/null || 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..c0c3da74a016 100755 --- a/common/travis/fetch_upstream.sh +++ b/common/travis/fetch_upstream.sh @@ -2,14 +2,9 @@ # # 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 +echo $(pwd) +git fetch --depth 200 https://github.com/void-linux/void-packages.git master From 48bca4d4f72f863a29b4b2c0055b54f865c8e26c 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 | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 95f1cd88e338..967d30dd733c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -26,7 +26,7 @@ jobs: LICENSE_LIST: common/travis/license.lst steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 with: fetch-depth: 200 - run: common/travis/fetch_upstream.sh @@ -73,7 +73,9 @@ jobs: # Upgrade again (in case there was a xbps update) xbps-install -yu - - uses: actions/checkout@v1 + # workaround until https://github.com/actions/checkout/pull/833 is merged + - run: git config --global alias.submodule '!true' + - 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..e1f2894890aa 100644 --- a/.github/workflows/cycles.yml +++ b/.github/workflows/cycles.yml @@ -25,7 +25,9 @@ jobs: xbps-install -yu # Install script dependencies xbps-install -y python3-networkx github-cli - - uses: actions/checkout@v1 + # workaround until https://github.com/actions/checkout/pull/833 is merged + - run: git config --global alias.submodule '!true' + - uses: actions/checkout@v3 with: fetch-depth: 1 - name: Create hostrepo and prepare masterdir @@ -35,8 +37,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 a29bdaadca0553cceb4b72eb37c5d60d62621021 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 c0c3da74a016..f108852370ed 100755 --- a/common/travis/fetch_upstream.sh +++ b/common/travis/fetch_upstream.sh @@ -2,9 +2,6 @@ # # changed_templates.sh -# required by git 2.35.2+ -git config --global --add safe.directory "$PWD" - /bin/echo -e '\x1b[32mFetching upstream...\x1b[0m' echo $(pwd) git fetch --depth 200 https://github.com/void-linux/void-packages.git master From 1d016ac40f71177350cef1c3772c8322ca8f036b 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"