Skip to content

fix #13998: Add script for pulling latest simplecpp version #7659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions tools/update-simplecpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env bash

set -e

files=(simplecpp.cpp simplecpp.h)
simplecpp_url="[email protected]:danmar/simplecpp.git"
commit_message_format="simplecpp: bump to %s"
cppcheck_dir="$(dirname "$(realpath --no-symlinks "${BASH_SOURCE[@]}")")/.."

tag="$1"
simplecpp_dir="$2"

[ -z "$tag" ] && {
>&2 echo "Usage: $0 <tag> [checked out simplecpp repo]"
exit 1
}

# Clone simplecpp if checked out repo was not provided
[ -z "$simplecpp_dir" ] && {
simplecpp_dir="$(mktemp -d)"
git clone "$simplecpp_url" "$simplecpp_dir"
}

# Checkout tag
git -C "$simplecpp_dir" -c advice.detachedHead=false checkout "$tag"

# Make sure tag is on the master branch
git -C "$simplecpp_dir" merge-base --is-ancestor "$tag" master || {
>&2 echo "Tag $tag is not on the master branch"
exit 1
}

# Make sure we don't commit any other files
git -C "$cppcheck_dir" reset --mixed

# Copy and stage files
for file in "${files[@]}"; do
source="$simplecpp_dir/$file"
dest="$cppcheck_dir/externals/simplecpp/$file"
cp "$source" "$dest"
git -C "$cppcheck_dir" add "$dest"
done

# Create commit
commit_message="$(printf "$commit_message_format" "$tag")"
git -C "$cppcheck_dir" commit -m "$commit_message"
Loading