Skip to content
Snippets Groups Projects
Commit 177e2640 authored by Ricardo Ortiz's avatar Ricardo Ortiz
Browse files

Add config for hooks and developer Utilities.

parent c647f4ab
No related branches found
No related tags found
No related merge requests found
[hooks]
url = http://public.kitware.com/GitSetup.git
[upstream]
url = https://gitlab.kitware.com/SimMedTK/SimMedTK.git
[gitlab]
host = gitlab.kitware.com
group-path = SimMedTK
group-name = SimMedTK
project-path = SimMedTK
project-name = SimMedTK
#!/usr/bin/env bash
echo "Setting up useful Git aliases..." &&
# General aliases that could be global
git config alias.pullall '!bash -c "git pull && git submodule update --init"' &&
git config alias.prepush 'log --graph --stat origin/master..' &&
# Alias to push the current topic branch to GitLab
git config alias.gitlab-push '!bash Utilities/GitSetup/git-gitlab-push' &&
true
#!/usr/bin/env bash
echo 'VTK no longer uses Gerrit. Please use GitLab.'
exit 1
#!/usr/bin/env bash
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
die() {
echo 'pre-commit hook failure' 1>&2
echo '-----------------------' 1>&2
echo '' 1>&2
echo "$@" 1>&2
exit 1
}
ExternalData_stage_linked_content() {
# Identify the hash algorithm used.
case "$file" in
*.md5) algo=MD5 ; base="${file/.md5}" ; validate="^[0-9a-fA-F]{32}$" ;;
*) die "$file: invalid content link (unrecognized extension)" ;;
esac
# Load and validate the hash stored in the staged blob.
hash=$(git cat-file blob $dst_obj) || hash=""
echo "$hash" | egrep-q "$validate" ||
die "$file: invalid content link (does not match '$validate')"
# Reject simultaneous raw file and content link.
files=$(git ls-files -- "$base")
if test -n "$files"; then
die "$file: content link may not coexist with $files"
fi
# Find the content referenced by the link.
staged="$(dirname "$file")/.ExternalData_${algo}_${hash}"
stored="${ExternalData_STORE}/$algo/$hash"
ref="refs/data/$algo/$hash"
obj=$(git rev-parse --verify -q "$ref") || obj=""
if test -z "$obj" -a -f "$staged"; then
# Content is staged by the ExternalData module. Store it in Git.
obj=$(git hash-object -w -- "$staged") ||
die "$file: git hash-object failed to load $staged"
git update-ref "$ref" "$obj" "" ||
die "$file: git update-ref failed to create $ref = $obj"
echo "$file: Added content to Git at $ref"
fi
# Move staged object to local store if it is in Git.
if test -f "$staged" && test -n "$obj"; then
mkdir -p "${stored%/*}" &&
mv "$staged" "$stored" &&
rm -f "$staged" &&
echo "$file: Added content to local store at $stored"
fi
# Report destination of content link.
if test -f "$stored"; then
echo "Content link $file -> $stored"
else
echo "Content link $file -> (object not in local store)"
fi
}
ExternalData_non_content_link() {
# Reject simultaneous raw file and content link.
files=$(git ls-files -- "$file.md5")
if test -n "$files"; then
die "$file: file may not coexist with $files"
fi
}
#-----------------------------------------------------------------------------
# Check that developmer setup is up-to-date.
lastSetupForDevelopment=$(git config --get hooks.SetupForDevelopment || echo 0)
eval $(grep '^SetupForDevelopment_VERSION=' "${BASH_SOURCE%/*}/../SetupForDevelopment.sh")
test -n "$SetupForDevelopment_VERSION" || SetupForDevelopment_VERSION=0
if test $lastSetupForDevelopment -lt $SetupForDevelopment_VERSION; then
die 'Developer setup in this work tree is out of date. Please re-run
Utilities/SetupForDevelopment.sh
'
fi
#-----------------------------------------------------------------------------
# Local ExternalData object repository.
ExternalData_STORE=".ExternalData"
# Process content links created by/for the CMake ExternalData module.
git diff-index --cached HEAD --diff-filter=AM |
while read src_mode dst_mode src_obj dst_obj status file; do
if echo "$dst_mode $file" | egrep-q '^100644 .*\.(md5)$'; then
ExternalData_stage_linked_content
else
ExternalData_non_content_link
fi
done || exit 1
#!/usr/bin/env bash
egrep-q() {
egrep "$@" >/dev/null 2>/dev/null
}
# First argument is file containing commit message.
commit_msg="$1"
# Check for our extra instructions.
egrep-q "^# Start the commit message" -- "$commit_msg" && return 0
# Insert our extra instructions.
commit_msg_tmp="$commit_msg.$$"
sed 's/^# \(On\|Not currently on any\) branch.*/'\
'# Start the commit message in "WIP: " to indicate Work In Progress\
# that is not yet ready to merge.\
#\
&/' "$commit_msg" > "$commit_msg_tmp" &&
mv "$commit_msg_tmp" "$commit_msg"
#!/usr/bin/env bash
cd "${BASH_SOURCE%/*}/.." &&
Utilities/GitSetup/setup-user && echo &&
Utilities/GitSetup/setup-hooks && echo &&
Utilities/Scripts/SetupGitAliases.sh && echo &&
(Utilities/GitSetup/setup-upstream ||
echo 'Failed to setup origin. Run this again to retry.') && echo &&
(Utilities/GitSetup/setup-gitlab ||
echo 'Failed to setup GitLab. Run this again to retry.') && echo &&
Utilities/GitSetup/tips
# Rebase master by default
git config rebase.stat true
git config branch.master.rebase true
# Record the version of this setup so Scripts/pre-commit can check it.
SetupForDevelopment_VERSION=2
git config hooks.SetupForDevelopment ${SetupForDevelopment_VERSION}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment