File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -e
4+
5+ files=(simplecpp.cpp simplecpp.h)
6+ simplecpp_url=" git@github.com:danmar/simplecpp.git"
7+ commit_message_format=" simplecpp: bump to %s"
8+ cppcheck_dir=" $( dirname " $( realpath --no-symlinks " ${BASH_SOURCE[@]} " ) " ) /.."
9+
10+ tag=" $1 "
11+ simplecpp_dir=" $2 "
12+
13+ [ -z " $tag " ] && {
14+ >&2 echo " Usage: $0 <tag> [checked out simplecpp repo]"
15+ exit 1
16+ }
17+
18+ # Clone simplecpp if checked out repo was not provided
19+ [ -z " $simplecpp_dir " ] && {
20+ simplecpp_dir=" $( mktemp -d) "
21+ git clone " $simplecpp_url " " $simplecpp_dir "
22+ }
23+
24+ # Checkout tag
25+ git -C " $simplecpp_dir " -c advice.detachedHead=false checkout " $tag "
26+
27+ # Make sure tag is on the master branch
28+ git -C " $simplecpp_dir " merge-base --is-ancestor " $tag " master || {
29+ >&2 echo " Tag $tag is not on the master branch"
30+ exit 1
31+ }
32+
33+ # Make sure we don't commit any other files
34+ git -C " $cppcheck_dir " reset --mixed
35+
36+ # Copy and stage files
37+ for file in " ${files[@]} " ; do
38+ source=" $simplecpp_dir /$file "
39+ dest=" $cppcheck_dir /externals/simplecpp/$file "
40+ cp " $source " " $dest "
41+ git -C " $cppcheck_dir " add " $dest "
42+ done
43+
44+ # Create commit
45+ commit_message=" $( printf " $commit_message_format " " $tag " ) "
46+ git -C " $cppcheck_dir " commit -m " $commit_message "
You can’t perform that action at this time.
0 commit comments