From 5b67f1651e7df5d242a384ad9c80097c6b5fe48a Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Sat, 18 Jul 2026 22:31:35 +0300 Subject: [PATCH] Relocate upstream version locks Keep the build-time version description outside GitHub metadata so external source managers that omit .github can build libusb-cmake. Move both locks and update CMake, the updater workflow, and documentation. Assisted-by: codex:gpt-5 --- .github/workflows/update-libusb.yml | 24 +++++++++---------- ...ream.describe => .libusb-upstream.describe | 0 ...ibusb-upstream.rev => .libusb-upstream.rev | 0 AGENTS.md | 4 ++++ CMakeLists.txt | 2 +- README.md | 3 ++- 6 files changed, 19 insertions(+), 14 deletions(-) rename .github/libusb-upstream.describe => .libusb-upstream.describe (100%) rename .github/libusb-upstream.rev => .libusb-upstream.rev (100%) diff --git a/.github/workflows/update-libusb.yml b/.github/workflows/update-libusb.yml index a3ac531..563e183 100644 --- a/.github/workflows/update-libusb.yml +++ b/.github/workflows/update-libusb.yml @@ -117,9 +117,9 @@ jobs: exit 1 fi - previous_sha="$(tr -d '\r\n' < .github/libusb-upstream.rev)" + previous_sha="$(tr -d '\r\n' < .libusb-upstream.rev)" if [[ ! "$previous_sha" =~ ^[0-9a-f]{40}$ ]]; then - echo "::error title=Invalid revision lock::.github/libusb-upstream.rev must contain one full lowercase commit SHA." + echo "::error title=Invalid revision lock::.libusb-upstream.rev must contain one full lowercase commit SHA." exit 1 fi @@ -130,21 +130,21 @@ jobs: git -C "$upstream_repo" fetch --no-tags --depth=1 "$UPSTREAM_URL" "$previous_sha" fi - previous_describe="$(tr -d '\r\n' < .github/libusb-upstream.describe)" + previous_describe="$(tr -d '\r\n' < .libusb-upstream.describe)" if [[ -z "$previous_describe" ]]; then - echo "::error title=Invalid description lock::.github/libusb-upstream.describe must contain one git-describe value." + echo "::error title=Invalid description lock::.libusb-upstream.describe must contain one git-describe value." exit 1 fi described_sha="$(git -C "$upstream_repo" rev-parse --verify "$previous_describe^{commit}" 2>/dev/null || true)" if [[ "$described_sha" != "$previous_sha" ]]; then - echo "::error title=Description lock mismatch::.github/libusb-upstream.describe does not resolve to .github/libusb-upstream.rev." + echo "::error title=Description lock mismatch::.libusb-upstream.describe does not resolve to .libusb-upstream.rev." exit 1 fi current_tree="$(git rev-parse 'HEAD:libusb')" locked_tree="$(git rev-parse "$previous_sha^{tree}")" if [[ "$current_tree" != "$locked_tree" ]]; then - echo "::error title=Vendored tree was edited::libusb/ no longer matches .github/libusb-upstream.rev; reconcile the local changes before replacing it." + echo "::error title=Vendored tree was edited::libusb/ no longer matches .libusb-upstream.rev; reconcile the local changes before replacing it." exit 1 fi @@ -242,9 +242,9 @@ jobs: # repository's required linear history. git rm -r --quiet -- libusb git read-tree --prefix=libusb/ -u "$TARGET_SHA^{tree}" - printf '%s\n' "$TARGET_SHA" > .github/libusb-upstream.rev - printf '%s\n' "$TARGET_DESCRIBE" > .github/libusb-upstream.describe - git add .github/libusb-upstream.rev .github/libusb-upstream.describe + printf '%s\n' "$TARGET_SHA" > .libusb-upstream.rev + printf '%s\n' "$TARGET_DESCRIBE" > .libusb-upstream.describe + git add .libusb-upstream.rev .libusb-upstream.describe staged_root="$(git write-tree)" imported_tree="$(git rev-parse "$staged_root:libusb")" @@ -254,9 +254,9 @@ jobs: exit 1 fi - unexpected_paths="$(git diff --cached --name-only | grep -Ev '^(libusb/|\.github/libusb-upstream\.(rev|describe)$)' || true)" + unexpected_paths="$(git diff --cached --name-only | grep -Ev '^(libusb/|\.libusb-upstream\.(rev|describe)$)' || true)" if [[ -n "$unexpected_paths" ]]; then - echo "::error title=Unexpected changed paths::The import changed files outside libusb/ and its revision lock." + echo "::error title=Unexpected changed paths::The import changed files outside libusb/ and its upstream locks." printf '%s\n' "$unexpected_paths" exit 1 fi @@ -302,7 +302,7 @@ jobs: - Upstream description: \`$TARGET_DESCRIBE\` - Workflow run: [$GITHUB_RUN_ID](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID) - The workflow verified that \`libusb/\` matches the resolved upstream tree byte-for-byte. The full revision and its \`git describe\` value are recorded in \`.github/libusb-upstream.rev\` and \`.github/libusb-upstream.describe\` for the CMake build. + The workflow verified that \`libusb/\` matches the resolved upstream tree byte-for-byte. The full revision and its \`git describe\` value are recorded in \`.libusb-upstream.rev\` and \`.libusb-upstream.describe\` for the CMake build. diff --git a/.github/libusb-upstream.describe b/.libusb-upstream.describe similarity index 100% rename from .github/libusb-upstream.describe rename to .libusb-upstream.describe diff --git a/.github/libusb-upstream.rev b/.libusb-upstream.rev similarity index 100% rename from .github/libusb-upstream.rev rename to .libusb-upstream.rev diff --git a/AGENTS.md b/AGENTS.md index 62854f8..ca40dc1 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -46,3 +46,7 @@ session itself should be included, as it is not publicly accessible. When a PR fixes an issue or relates to / replaces another issue, the PR description should include a reference to the issue number after the main description but before the `Assisted-by:` attribution, e.g. `Fixes: #123` or `Closes: #124`. + +## GitHub metadata + +Do not place files under `.github/` unless GitHub itself, including GitHub Actions, requires that location. diff --git a/CMakeLists.txt b/CMakeLists.txt index 126aadb..8146ebb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,7 @@ generate_config_file() set(LIBUSB_VERSION_DESCRIBE_ROOT "${CMAKE_CURRENT_BINARY_DIR}/libusb-version-describe") set(LIBUSB_VERSION_DESCRIBE_HEADER "${LIBUSB_GEN_INCLUDES}/version_describe.h") -set(LIBUSB_VERSION_DESCRIBE_LOCK "${CMAKE_CURRENT_SOURCE_DIR}/.github/libusb-upstream.describe") +set(LIBUSB_VERSION_DESCRIBE_LOCK "${CMAKE_CURRENT_SOURCE_DIR}/.libusb-upstream.describe") set(LIBUSB_VERSION_DESCRIBE_SCRIPT "${LIBUSB_SOURCE_ROOT}/build-aux/gen-describe.sh") set(LIBUSB_VERSION_DESCRIBE_DEPENDS) diff --git a/README.md b/README.md index 30e8086..39693cc 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Send changes to the bundled library sources to [libusb], not here. Maintainers can run the **Update libusb** workflow with an upstream branch, tag, or full commit SHA. It imports the exact upstream tree, records the -revision in [.github/libusb-upstream.rev](.github/libusb-upstream.rev), and +revision in [.libusb-upstream.rev](.libusb-upstream.rev) and the upstream +description in [.libusb-upstream.describe](.libusb-upstream.describe), and opens a draft PR. This keeps updates compatible with the repository's required linear history.