mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-25 01:28:50 -05:00
update-third-party: update from upstream
Update to `update-common.sh` from commit `7134d5ebef` in
https://gitlab.kitware.com/utils/git-import-third-party
This commit is contained in:
@@ -42,6 +42,22 @@
|
||||
# For convenience, the function may use the "git_archive" function which
|
||||
# does a standard "git archive" extraction using the (optional) "paths"
|
||||
# variable to only extract a subset of the source tree.
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
# To update third party packages from git repositories with submodule,
|
||||
# you will need to install the "git-archive-all" Python package with
|
||||
#
|
||||
# pip install git-archive-all
|
||||
#
|
||||
# or install it from https://github.com/Kentzo/git-archive-all.
|
||||
#
|
||||
# This package installs a script named "git-archive-all" where pip
|
||||
# installs executables. If you run pip under your user privileges (i.e.,
|
||||
# not using "sudo"), this location may be $HOME/.local/bin. Make sure
|
||||
# that directory is in your path so that git can find the
|
||||
# "git-archive-all" script.
|
||||
#
|
||||
########################################################################
|
||||
|
||||
########################################################################
|
||||
@@ -52,11 +68,24 @@ git_archive () {
|
||||
tar -C "$extractdir" -x
|
||||
}
|
||||
|
||||
confirm_archive_all_exists () {
|
||||
which git-archive-all || die "git requires an archive-all command. Please run 'pip install git-archive-all'"
|
||||
}
|
||||
|
||||
git_archive_all () {
|
||||
confirm_archive_all_exists
|
||||
local tmptarball="temp.tar"
|
||||
git archive-all --prefix="" "$tmptarball"
|
||||
mkdir -p "$extractdir/$name-reduced"
|
||||
tar -C "$extractdir/$name-reduced" -xf "$tmptarball" $paths
|
||||
rm -f "$tmptarball"
|
||||
}
|
||||
|
||||
disable_custom_gitattributes() {
|
||||
pushd "${extractdir}/${name}-reduced"
|
||||
# Git does not allow custom attributes in a subdirectory where we
|
||||
# are about to merge the `.gitattributes` file, so disable them.
|
||||
sed -i '/^\[attr\]/ {s/^/#/}' .gitattributes
|
||||
sed -i '/^\[attr\]/ {s/^/#/;}' .gitattributes
|
||||
popd
|
||||
}
|
||||
|
||||
@@ -71,6 +100,9 @@ warn () {
|
||||
|
||||
readonly regex_date='20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]'
|
||||
readonly basehash_regex="$name $regex_date ([0-9a-f]*)"
|
||||
readonly toplevel_dir="$( git rev-parse --show-toplevel )"
|
||||
|
||||
cd "$toplevel_dir"
|
||||
|
||||
########################################################################
|
||||
# Sanity checking
|
||||
@@ -95,7 +127,7 @@ if [ ! -d "$(git rev-parse --show-toplevel)/$subtree" ]; then
|
||||
else
|
||||
readonly basehash="$( git rev-list --author="$ownership" --grep="$basehash_regex" -n 1 HEAD )"
|
||||
fi
|
||||
readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p}' | egrep '^[0-9a-f]+$' )"
|
||||
readonly upstream_old_short="$( git cat-file commit "$basehash" | sed -n '/'"$basehash_regex"'/ {s/.*(//;s/)//;p;}' | egrep '^[0-9a-f]+$' )"
|
||||
|
||||
[ -n "$basehash" ] || \
|
||||
warn "'basehash' is empty; performing initial import"
|
||||
@@ -111,7 +143,7 @@ readonly extractdir="$workdir/extract"
|
||||
trap "rm -rf '$workdir'" EXIT
|
||||
|
||||
# Get upstream
|
||||
git clone "$repo" "$upstreamdir"
|
||||
git clone --recursive "$repo" "$upstreamdir"
|
||||
|
||||
if [ -n "$basehash" ]; then
|
||||
# Remove old worktrees
|
||||
@@ -120,7 +152,7 @@ if [ -n "$basehash" ]; then
|
||||
git worktree add "$extractdir" "$basehash"
|
||||
# Clear out the working tree
|
||||
pushd "$extractdir"
|
||||
git ls-files | xargs rm -v
|
||||
git ls-files -z --recurse-submodules | xargs -0 rm -v
|
||||
find . -type d -empty -delete
|
||||
popd
|
||||
else
|
||||
@@ -132,6 +164,8 @@ fi
|
||||
# Extract the subset of upstream we care about
|
||||
pushd "$upstreamdir"
|
||||
git checkout "$tag"
|
||||
git submodule sync --recursive
|
||||
git submodule update --recursive --init
|
||||
readonly upstream_hash="$( git rev-parse HEAD )"
|
||||
readonly upstream_hash_short="$( git rev-parse --short=8 "$upstream_hash" )"
|
||||
readonly upstream_datetime="$( git rev-list "$upstream_hash" --format='%ci' -n 1 | grep -e "^$regex_date" )"
|
||||
|
||||
Reference in New Issue
Block a user