Skip to content

Commit

Permalink
Remove using "rev-list" to get source/target commit for PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
ywei2017 committed May 10, 2022
1 parent 5a36bc2 commit a402a26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions assets/helpers/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,17 @@ pullrequest_metadata() {
# $1: pull request number
# $2: pull request repository
# $3: skip ssl verification
# $4: soucre_commmit
# $5: target_commmit

local source_commit=$(git rev-list --parents -1 $(git rev-parse HEAD) | awk '{print $3}')
local target_commit=$(git rev-list --parents -1 $(git rev-parse HEAD) | awk '{print $2}')
# No longer working with vSphere 7
#local source_commit=$(git rev-list --parents -1 $(git rev-parse HEAD) | awk '{print $3}')
#local target_commit=$(git rev-list --parents -1 $(git rev-parse HEAD) | awk '{print $2}')

jq -n "[]" | \
add_pullrequest_metadata_basic "$1" "$2" "$3" | \
add_pullrequest_metadata_commit "source" "$source_commit" | \
add_pullrequest_metadata_commit "target" "$target_commit"
add_pullrequest_metadata_commit "source" "$4" | \
add_pullrequest_metadata_commit "target" "$5"
}

configure_credentials() {
Expand Down
2 changes: 1 addition & 1 deletion assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,5 @@ git config --add pullrequest.branch "$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
2 changes: 1 addition & 1 deletion assets/out
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,5 @@ jq -n "{
hash: \"$prq_hash\",
date: \"$PULL_REQUEST_DATE\"
},
metadata: $(pullrequest_metadata "$prq_number" "$uri" "$skip_ssl_verification")
metadata: $(pullrequest_metadata "$prq_number" "$uri" "$skip_ssl_verification" "$source_commit" "$target_commit" )
}" >&3

0 comments on commit a402a26

Please sign in to comment.