-
Notifications
You must be signed in to change notification settings - Fork 8
Resolve bitBucket 7.x Issue #22
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ sleep_between_fetches=$(jq -r '.source.sleep_between_fetches // "0"' < "$payload | |
| sleep_between_fetches=$(echo "$sleep_between_fetches" | sed 's/[^0-9\.]//g') | ||
| rebuild_when_target_changed=$(jq -r '.source.rebuild_when_target_changed // "false"' < "$payload") | ||
| rebuild_phrase=$(jq -r '.source.rebuild_phrase // "test this please"' < "$payload") | ||
| max_pr_to_check=$(jq -r '.source.max_pr_to_check // "999"' < "$payload") | ||
| CURRENT_VERSION_DATE=$(jq -r '.version.date // "0"' < "$payload") | ||
|
|
||
| configure_git_ssl_verification "$skip_ssl_verification" | ||
|
|
@@ -60,7 +61,8 @@ fi | |
| # collect all pull requests from uri | ||
| REMOTES=$(git ls-remote "$uri") | ||
| set +e | ||
| PULL_REQUESTS=$(echo "$REMOTES" | grep -E "/pull\\-requests/[0-9]+/${prq_branch}") | ||
| PULL_REQUESTS=$(echo "$REMOTES" | grep -E "/pull\\-requests/[0-9]+/${prq_branch}" | \ | ||
| sort -t / -k 3 -n -r | head -n $max_pr_to_check) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sort by the PR number and sort in reverse, taking the top |
||
| set -e | ||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,13 @@ if test "$depth" -gt 0 2> /dev/null; then | |
| depthflag="--depth $depth" | ||
| fi | ||
|
|
||
| branch="pull-requests/${prq_id}/merge" | ||
| # see comments in "check" resource | ||
| branch="pull-requests/${prq_id}" | ||
| if [ "$rebuild_when_target_changed" == "true" ]; then | ||
| branch="$branch/merge" | ||
| else | ||
| branch="$branch/from" | ||
| fi | ||
|
|
||
| log "Cloning $uri in $destination" | ||
| git clone $depthflag "$uri" "$destination" | ||
|
|
@@ -118,20 +124,6 @@ if [ "$disable_git_lfs" != "true" ]; then | |
| git submodule foreach "git lfs fetch && git lfs checkout" | ||
| fi | ||
|
|
||
| # calculate source and target commit | ||
| source_commit=$(git rev-list --parents -1 $ref | awk '{print $3}') | ||
| target_commit=$(git rev-list --parents -1 $ref | awk '{print $2}') | ||
|
|
||
| if [ -z "$source_commit" ]; then | ||
| log "Unable to determine source commit from merge commit $ref. Please verify depth configuration." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$target_commit" ]; then | ||
| log "Unable to determine target commit from merge commit $ref. Please verify depth configuration." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # parse uri and retrieve host | ||
| uri_parser "$uri" | ||
| repo_host="${uri_schema}://${uri_address}" | ||
|
|
@@ -147,19 +139,36 @@ prq=$(bitbucket_pullrequest "$repo_host" "$repo_project" "$repo_name" "$prq_id" | |
| if [ "$prq" != "NO_SUCH_PULL_REQUEST" ] && \ | ||
| [ "$prq" != "ALREADY_MERGED" ] && \ | ||
| [ "$prq" != "DECLINED" ]; then | ||
| branch=$(echo "$prq" | jq -r '.fromRef.displayId') | ||
| from_branch=$(echo "$prq" | jq -r '.fromRef.displayId') | ||
| fi | ||
|
|
||
| # calculate source and target commit | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. get the info from the API, instead of |
||
| source_commit=$(echo "$prq" | jq -r '.fromRef.latestCommit') | ||
| target_commit=$(echo "$prq" | jq -r '.toRef.latestCommit') | ||
| if [ -z "$source_commit" ]; then | ||
| log "Unable to determine source commit from merge commit $ref. Please verify depth configuration." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [ -z "$target_commit" ]; then | ||
| log "Unable to determine target commit from merge commit $ref. Please verify depth configuration." | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$branch" == */from ]]; then | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the source branch is |
||
| log "Merge in changes from $target_commit to pullrequest/*/from, to emulate pullrequest/*/merge" | ||
| git merge $target_commit | ||
| fi | ||
|
|
||
| # expose configuration of pull request that can be used in container | ||
| git config --add pullrequest.id $prq_id | ||
| git config --add pullrequest.source $source_commit | ||
| git config --add pullrequest.target $target_commit | ||
| git config --add pullrequest.merge $ref | ||
| git config --add pullrequest.date "$prq_date" | ||
| git config --add pullrequest.branch "$branch" | ||
| git config --add pullrequest.branch "$from_branch" | ||
|
|
||
| jq -n "{ | ||
| version: $(jq '.version' < "$payload"), | ||
| metadata: $(pullrequest_metadata "$prq_id" "$uri" "$skip_ssl_verification") | ||
| metadata: $(pullrequest_metadata "$prq_id" "$uri" "$skip_ssl_verification" "$source_commit" "$target_commit" ) | ||
| }" >&3 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| #!/bin/sh | ||
| ## Why is this needed instead of inistalling from apk? | ||
|
|
||
| set -eu | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our corporate bitBucket server is pretty slow, and heavily loaded. And it has days REALLY, REALLY slow, so after much hesitation I added this flag. For most people, nothing needs to be done, and a default of
999is plenty enough. For the rest of us, giving it a limit speeds things up quite a bit.