Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/lfs #1

Merged
merged 3 commits into from
Jul 14, 2022
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ FROM alpine:3.11

RUN apk add --no-cache bash
RUN apk --no-cache add git
RUN apk --no-cache add git-lfs
RUN apk --no-cache add jq


COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ The path to the submodule, this is required. Do not include leading or trailing
### `branch` (optional)
The name of a branch that the submodule hash must be on (after the push or on the head PR branch)

### `first_parent` (optional)
Require the submodule's checked-out commit to be an ancestor of the specified branch strictly along the path following first parents only. That is, the submodule's current HEAD must either currently be or have at some point in the past been the tip of the branch specified.

### `pass_if_unchanged` (optional)
For pull request only, if this is included the check will automatically pass if none of the commits modify the submodule.

Expand Down Expand Up @@ -52,6 +55,7 @@ jobs:
with:
path: "path/to/submodule"
branch: "main"
first_parent: true
fetch_depth: "50"
pass_if_unchanged: true
require_head: true
Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ inputs:
description: "Which branch the submodule must be on"
required: false
default: ''
first_parent:
description: "Require submodule commit to be an ancestor of specified branch strictly along first-parent path"
required: false
default: ''
pass_if_unchanged:
description: "If the check should always pass if the submodule hasn't been changed on a branch/commit"
required: false
Expand All @@ -32,6 +36,7 @@ inputs:
description: "Override the path to the github event json file. Used for testing."
required: false
default: ''

outputs:
fails:
description: "Cause of failure, if run failed"
Expand Down
8 changes: 8 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ if [[ ! -z "${INPUT_BRANCH}" ]]; then
echo "${BRANCHES}" | grep "/${INPUT_BRANCH}$" || fail "Submodule ${INPUT_PATH} Hash ${SUBMODULE_HASH} is not on branch ${INPUT_BRANCH}"
echo "Submodule is on branch ${INPUT_BRANCH}"
echo "::endgroup::"

if [[ ! -z "${INPUT_FIRST_PARENT}" ]]; then
echo "::group::Check First-Parent Ancestry"
git rev-list --first-parent ${INPUT_BRANCH} --not ${SUBMODULE_HASH}^@ | grep "${SUBMODULE_HASH}" || fail "Commit ${SUBMODULE_HASH} is not a first-parent ancestor of the tip of ${INPUT_BRANCH}"
echo "Commit ${SUBMODULE_HASH} is a first-parent ancestor of the tip of ${INPUT_BRANCH}"
echo "::endgroup::"
fi

fi


Expand Down