diff options
| author | Richard J. Knight <rjknight@us.ibm.com> | 2017-10-13 15:49:25 -0500 |
|---|---|---|
| committer | Richard J. Knight <rjknight@us.ibm.com> | 2017-10-17 15:05:22 -0500 |
| commit | 41e7df45e64f623499b8d286a4012e6e7d24eaf6 (patch) | |
| tree | e7a54e4950d2610c3fddeaf2b74b53b424315bf1 /tools/envsetup | |
| download | talos-hcode-41e7df45e64f623499b8d286a4012e6e7d24eaf6.tar.gz talos-hcode-41e7df45e64f623499b8d286a4012e6e7d24eaf6.zip | |
Initial hcode commit
Change-Id: I2c6c9b05c6afbd7732f472ea9cf049d00c5cad45
Diffstat (limited to 'tools/envsetup')
| -rwxr-xr-x | tools/envsetup/gerrit-hostname | 79 | ||||
| -rwxr-xr-x | tools/envsetup/setupgithooks | 64 |
2 files changed, 143 insertions, 0 deletions
diff --git a/tools/envsetup/gerrit-hostname b/tools/envsetup/gerrit-hostname new file mode 100755 index 00000000..443a6598 --- /dev/null +++ b/tools/envsetup/gerrit-hostname @@ -0,0 +1,79 @@ +#!/usr/bin/perl +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: tools/envsetup/gerrit-hostname $ +# +# OpenPOWER HCODE Project +# +# COPYRIGHT 2015,2017 +# [+] International Business Machines Corp. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG + +## Usage +# It is imperative that there are no prints other than the die command or +# "export GERRIT_SRV=$host" as this script is evaluated by env.bash and not +# called directly + +use strict; + +my $homeDir = $ENV{'HOME'}; +my $sshConfigFile = $homeDir."/.ssh/config"; +# If the server changes location these will change +my $gerritHostname = "ralgit01.raleigh.ibm.com"; +my $gerritPort = "29418"; + +open(CONFIG, "< $sshConfigFile") or die " $? can't open $sshConfigFile: $!" ; + +my $host = ""; +my $hostname = ""; +my $port = ""; +while (my $line = <CONFIG>) +{ + # Whitespace after each constant is important + if ($line =~ m/^Host [^\s]/) + { + ($host) = $line =~ m/^Host (.*?)\s/; + } + elsif ($line =~ m/Hostname [^\s]/) + { + ($hostname) = $line =~ m/^*Hostname (.*)/; + } + elsif ($line =~ m/Port [^\s]/) + { + ($port) = $line =~ m/^*Port (.*)/; + } + + # Check if we found the gerrit host name + if ($host ne "" && + $hostname eq $gerritHostname && + $port eq $gerritPort) + { + last; + } +} +close(CONFIG); + +if ($host eq "") +{ + die "Error> Could not find gerrit host in $sshConfigFile"; +} +else +{ + # Set gerrit server env variable by returning command to env.bash + print "export GERRIT_SRV=$host\n"; +} diff --git a/tools/envsetup/setupgithooks b/tools/envsetup/setupgithooks new file mode 100755 index 00000000..12444caf --- /dev/null +++ b/tools/envsetup/setupgithooks @@ -0,0 +1,64 @@ +#!/bin/bash +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: tools/envsetup/setupgithooks $ +# +# OpenPOWER HCODE Project +# +# COPYRIGHT 2015,2017 +# [+] International Business Machines Corp. +# +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. See the License for the specific language governing +# permissions and limitations under the License. +# +# IBM_PROLOG_END_TAG + +# Each developer runs this from the git_repo base dir, where it will copy the +# needed scripts into .git/hooks/ directory and make them executable. + +if [ -d $HOOKSDIR ] +then + + # Get hooks from Gerrit, if needed. + if [ ! -f $HOOKSDIR/commit-msg ] + then + echo "Copying Gerrit hooks..." + scp -p -q $GERRIT_SRV:hooks/commit-msg $HOOKSDIR || exit -1 + fi + + # Copy custom pre/post commit hooks from tools directory. + if [ -f "$EKBHOOKSDIR/pre-commit" -a \ + -f "$EKBHOOKSDIR/post-commit" ] + then + echo "Copying pre/post commit hooks..." + + cp $EKBHOOKSDIR/pre-commit $HOOKSDIR/ || exit -1 + cp $EKBHOOKSDIR/pre-commit $HOOKSDIR/pre-applypatch || exit -1 + cp $EKBHOOKSDIR/post-commit $HOOKSDIR/ || exit -1 + + chmod u+x $HOOKSDIR/pre-commit || exit -1 + chmod u+x $HOOKSDIR/pre-applypatch || exit -1 + chmod u+x $HOOKSDIR/post-commit || exit -1 + + else + echo "Cannot find or access pre or post commit scripts" + exit 0 + fi + +else + echo "Cannot find or access .git/hooks directory" + exit 0 +fi + +exit 0 |

