Skip to content
Snippets Groups Projects
Commit 7d9b3547 authored by Oliver Sander's avatar Oliver Sander
Browse files

Add new command "vcsetup" to dunecontrol

This patch adds the new command "vcsetup" to dunecontrol. This command
is intended to perform various setup actions on a module that has been
checked out from a version control system.

For now, the command

- installs the whitespace hook bin/git-whitespace-hook as a Git pre-commit hook
  if all of the following conditions are met:
  - the current module is a Git repository
  - the dune.module file contains the line "Whitespace-Hook: Yes"
  - there is no existing pre-commit hook that would be overwritten
  The script detects older versions of the whitespace hook and updates them
  if necessary.

- applies Git configuration settings from the file .vcsetup/config.
  The contents of the file is simply fed to "git config" line by line. That
  way, Git configuration keys can be set by simply adding a line of the form
  "key value". Lines starting with "#" are filtered out and can thus be used
  for comments.

- runs all executable files in the directory .vcsetup/run.d
  This can be used for more elaborate setups. Note that these scripts are run
  if any of the following files/directories are found: .git .svn CVS stamp-vc

[[Imported from SVN: r7467]]
parent 78f7806b
No related branches found
No related tags found
No related merge requests found
......@@ -221,10 +221,11 @@ esac'
}
# list of all dunecontrol commands
COMMANDS="printdeps update autogen configure make all exec bexec status svn"
COMMANDS="printdeps vcsetup update autogen configure make all exec bexec status svn"
# help string for the commands
printdeps_HELP="print recursive dependencies of a module"
vcsetup_HELP="setup version control repository (Git etc.) or working copy (SVN)"
update_HELP="updated all modules from the repository"
autogen_HELP="run the autogen.sh script for each module. Does nothing, if CMake is activated"
configure_HELP="run configure or cmake for each module"
......@@ -312,6 +313,62 @@ run_default_status () {
echo -e "$color[$text]$reset $name"
}
run_default_vcsetup() {
if [ -d .git ]; then
# Read Whitespace-Hook setting from dune.module file
local SETUPGITHOOK="$($GREP -i "^[$BLANK]*Whitespace-Hook:" dune.module | cut -d ':' -f2 | eval $PARSER_TRIM | tr '[:upper:]' '[:lower:]')"
if [ "x$SETUPGITHOOK" = "xyes" ]; then
# we have to install the Git whitespace hook
if [ ! -e .git/hooks/pre-commit ]; then
# there is no hook yet, we can safely install ours
echo "--> Installing Git pre-commit hook to enforce whitespace policy"
cp -p $PREFIX_DIR/bin/git-whitespace-hook .git/hooks/pre-commit
else
# there is already a hook, check whether it is our whitespace hook
local HOOKTAG="$(head -n 2 .git/hooks/pre-commit | tail -n 1)"
if [ "x$HOOKTAG" = "x# dune-git-whitespace-hook" ]; then
if [ $PREFIX_DIR/bin/git-whitespace-hook -nt .git/hooks/pre-commit ]; then
echo "--> Updating Git pre-commit hook with newer version"
cp -p $PREFIX_DIR/bin/git-whitespace-hook .git/hooks/pre-commit
fi
else
echo "WARNING: Existing pre-commit hook found!"
echo "WARNING: Skipping installation of DUNE whitespace hook!"
echo "WARNING: If you want to contribute patches to DUNE, you should make sure to call the whitespace hook"
echo "WARNING: (dune-common/bin/git-whitespace-hook) from you custom pre-commit hook, otherwise your commits"
echo "WARNING: might contain trailing whitespace and will not apply cleanly to the official repositories!"
fi
fi
fi
# Apply git configuration settings
if [ -f .vcsetup/config ]; then
echo -n "--> Setting Git configuration entries... "
cat .vcsetup/config | while read; do
# Filter out comments
COMMENT="$(echo $REPLY | $GREP '^#')"
if [ ! "x$COMMENT" = "x$REPLY" ]; then
git config $REPLY
fi
done
echo "done"
fi
fi
# Run custom setup scripts
if [ -d .git -o -d .svn -o -d CVS -o -f stamp-vc ]; then
if [ -d .vcsetup/run.d ]; then
for SCRIPT in .vcsetup/run.d/* ; do
if [ -x "$SCRIPT" ]; then
echo "--> Running $SCRIPT"
"$SCRIPT"
fi
done
fi
fi
}
run_default_update () {
DUNELINK=0
if test -L dune; then
......
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