File: update_travis-mac_branch.sh

package info (click to toggle)
copyq 3.7.3-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 10,480 kB
  • sloc: cpp: 51,894; sh: 734; python: 211; xml: 57; makefile: 34
file content (28 lines) | stat: -rwxr-xr-x 830 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
# Rebase last commit from target branch to source branch and push.
source_branch="master"
target_branch="travis-mac"
remote="origin"
msg="Updated Travis CI build file for OS X"
keep_files=(
    .travis.yml
)

branch_name () {
    git rev-parse --abbrev-ref "$1"
}

current_branch=$(branch_name HEAD)

if [ "$current_branch" == "$source_branch" ]; then
    echo "** Rebasing last commit from \"$target_branch\" to \"$source_branch\"."
    git checkout -b "$target_branch" &&
        git checkout "$remote/$target_branch" -- "${keep_files[@]}" &&
        git add "${keep_files[@]}" &&
        git commit --message "$msg" &&
        git push --force "$remote" "HEAD:$target_branch" ||
        echo "** Failed to update \"$target_branch\" branch!"
    git checkout "$current_branch"
    git branch -D "$target_branch"
fi