File: is_pr_merge.sh

package info (click to toggle)
node-mapnik 3.7.2%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 15,376 kB
  • sloc: cpp: 16,551; xml: 961; sh: 522; makefile: 80; lisp: 10
file content (28 lines) | stat: -rwxr-xr-x 854 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash

set -eu pipefail

: '

This script is designed to detect if a gitsha represents a normal
push commit (to any branch) or whether it represents travis attempting
to merge between the origin and the upstream branch.

For more details see: https://docs.travis-ci.com/user/pull-requests

TODO: can ${TRAVIS_PULL_REQUEST} be used instead of the below git commands?
'

# Get the commit message via git log
# This should always be the exact text the developer provided
COMMIT_LOG=$(git log --format=%B --no-merges -n 1 | tr -d '\n')

# Get the commit message via git show
# If the gitsha represents a merge then this will
# look something like "Merge e3b1981 into 615d2a3"
# Otherwise it will be the same as the "git log" output
COMMIT_SHOW=$(git show -s --format=%B | tr -d '\n')

if [[ "${COMMIT_LOG}" != "${COMMIT_SHOW}" ]]; then
   echo true
fi