File: subtree-sync.sh

package info (click to toggle)
rustc 1.88.0%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 934,168 kB
  • sloc: xml: 158,127; python: 36,062; javascript: 19,855; sh: 19,700; cpp: 18,947; ansic: 12,993; asm: 4,792; makefile: 690; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (52 lines) | stat: -rwxr-xr-x 1,371 bytes parent folder | download | duplicates (12)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

set -eou pipefail

git fetch origin
pushd $2
git fetch origin
popd

if [ "$(git rev-parse --show-prefix)" != "" ]; then
    echo "Run this script from the git root" >&2
    exit 1
fi

if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/master)" ]; then
    echo "$(pwd) is not at origin/master" >&2
    exit 1
fi

if [ ! -f library/portable-simd/git-subtree.sh ]; then
    curl -sS https://raw.githubusercontent.com/bjorn3/git/tqc-subtree-portable/contrib/subtree/git-subtree.sh -o library/portable-simd/git-subtree.sh
    chmod +x library/portable-simd/git-subtree.sh
fi

today=$(date +%Y-%m-%d)

case $1 in
    "push")
        upstream=rust-upstream-$today
        merge=sync-from-rust-$today

        pushd $2
        git checkout master
        git pull
        popd

        library/portable-simd/git-subtree.sh push -P library/portable-simd $2 $upstream

        pushd $2
        git checkout -B $merge origin/master
        git merge $upstream
        popd
        echo "Branch \`$merge\` created in \`$2\`. You may need to resolve merge conflicts."
        ;;
    "pull")
        branch=sync-from-portable-simd-$today

        git checkout -B $branch
        echo "Creating branch \`$branch\`... You may need to resolve merge conflicts."
        library/portable-simd/git-subtree.sh pull -P library/portable-simd $2 origin/master
        ;;
esac