Skip to content

Commit

Permalink
simplified from commit definition logic
Browse files Browse the repository at this point in the history
  • Loading branch information
oakrizan committed May 20, 2024
1 parent 4128eab commit 38a83b2
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions .buildkite/scripts/changesets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,15 @@ defineExclusions() {
}

defineFromCommit() {
local previousCommit
local changeTarget=${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-$BUILDKITE_BRANCH}

previousCommit=$(git rev-parse HEAD^)

from=${changeTarget:+"origin/$changeTarget"}
from=${from:-$previousCommit}
from=${from:-$BUILDKITE_COMMIT}

echo "--- Change target: $changeTarget"
echo "--- Previous commit: $previousCommit"
echo "--- Defined from commit: $from"

lastCommit=$(git rev-parse HEAD)
if [[ "$BUILDKITE_PULL_REQUEST" != "false" ]]; then
baseCommit=$(git rev-parse "$lastCommit"^)
if [[ -z ${changeTarget+x} ]]; then
# If not a PR (no target branch) - use last commit
from=$(git rev-parse HEAD^)
else
baseCommit=$lastCommit
# If it's a PR - add "origin/"
from="origin/$changeTarget"
fi
echo "--- Defined base commit: $baseCommit"
}

getMatchingModules() {
Expand Down

0 comments on commit 38a83b2

Please sign in to comment.