-
-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #306 from stgraber/main
Test bugfixes and typos
- Loading branch information
Showing
4 changed files
with
30 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
#!/bin/sh -eu | ||
|
||
# Default target branch. | ||
target_branch="main" | ||
if [ -n "${GITHUB_ACTIONS:-}" ]; then | ||
# Target branch when running in github actions (see https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables). | ||
target_branch="" | ||
if [ -n "${GITHUB_BASE_REF:-}" ]; then | ||
# Target branch when scanning a Github pull request | ||
target_branch="${GITHUB_BASE_REF}" | ||
elif [ -n "${GITHUB_BEFORE:-}" ]; then | ||
# Target branch when scanning a Github merge | ||
target_branch="${GITHUB_BEFORE}" | ||
elif [ -n "${1:-}" ]; then | ||
# Allow a target branch parameter. | ||
target_branch="${1}" | ||
else | ||
# Default target branch. | ||
for branch in main origin lxc/main; do | ||
if git show-ref --quiet "refs/heads/${branch}" >/dev/null 2>&1; then | ||
target_branch="${branch}" | ||
break | ||
fi | ||
done | ||
fi | ||
|
||
# Check if we found a target branch. | ||
if [ -z "${target_branch}" ]; then | ||
echo "The target branch for golangci couldn't be found, skipping." | ||
return | ||
fi | ||
|
||
# Gets the most recent commit hash from the target branch. | ||
rev="$(git log "${target_branch}" --oneline --no-abbrev-commit -n1 | cut -d' ' -f1)" | ||
|
||
echo "Checking for golangci-lint errors between HEAD and ${target_branch}..." | ||
golangci-lint run --timeout 5m --new --new-from-rev "${rev}" | ||
golangci-lint run --timeout 5m --new --new-from-rev "${rev}" |