Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/update-libusb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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")"
Expand All @@ -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
Expand Down Expand Up @@ -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.

<!-- libusb-upstream-commit: $TARGET_SHA -->

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading