Handle unset git information
In CI or in a new user's case they may not have properly configured their git information prior to running the bootstrap command. This change temporarily adds a name and email for the initial bootstrap commit if the global information is not set. Instructions on how to configure this are also provided when this case occurs. Change-Id: Ib1916b11ec4cb544079075c7602081a147925067
This commit is contained in:
parent
4cbb48893e
commit
d177cd01c0
@ -39,6 +39,36 @@ if [ -z "$proj" ] || [ -z "$user" ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
check_gerrit_user() {
|
||||||
|
if [[ -z $(git config --global user.name) ]]; then
|
||||||
|
echo "WARNING: Git commiter name is not set, setting it locally..."
|
||||||
|
git config --local user.name "Puppet OpenStack Cookiecutter"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z $(git config --global user.email) ]]; then
|
||||||
|
echo "WARNING: Git commiter email is not set, setting it locally..."
|
||||||
|
git config --local user.email "puppet-openstack-cookiecutter@example.com"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_gerrit_user() {
|
||||||
|
if [[ -n $(git config --local user.name) || -n $(git config --local user.email) ]]; then
|
||||||
|
echo "
|
||||||
|
WARNING: We configured a temporary user/email for the initial commit.
|
||||||
|
You will need to reset this information prior to running git review. Please
|
||||||
|
configure your name and email in the git config and update the previous
|
||||||
|
commit with your author information.
|
||||||
|
|
||||||
|
git config --global user.name "Your Name"
|
||||||
|
git config --global user.email "your@email"
|
||||||
|
cd `pwd`
|
||||||
|
git commit --amend --author='Your Name <your@email>'"
|
||||||
|
|
||||||
|
git config --local --unset user.name
|
||||||
|
git config --local --unset user.email
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ -z "${testing}" ]; then
|
if [ -z "${testing}" ]; then
|
||||||
tmp_var="/tmp/puppet-${proj}"
|
tmp_var="/tmp/puppet-${proj}"
|
||||||
else
|
else
|
||||||
@ -94,6 +124,8 @@ fi
|
|||||||
# Step 3: Add the cookiecutter file and make an initial commit
|
# Step 3: Add the cookiecutter file and make an initial commit
|
||||||
#
|
#
|
||||||
pushd cookiecutter/puppet-$proj
|
pushd cookiecutter/puppet-$proj
|
||||||
|
|
||||||
|
check_gerrit_user
|
||||||
git add --all && git commit -am "puppet-${proj}: Initial Commit
|
git add --all && git commit -am "puppet-${proj}: Initial Commit
|
||||||
|
|
||||||
This is the initial commit for puppet-${proj}.
|
This is the initial commit for puppet-${proj}.
|
||||||
@ -101,6 +133,7 @@ It has been automatically generated using cookiecutter[1] and msync[2]
|
|||||||
[1] https://github.com/openstack/puppet-openstack-cookiecutter
|
[1] https://github.com/openstack/puppet-openstack-cookiecutter
|
||||||
[2] https://github.com/openstack/puppet-modulesync-configs
|
[2] https://github.com/openstack/puppet-modulesync-configs
|
||||||
"
|
"
|
||||||
|
cleanup_gerrit_user
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Step 4: Retrieve the puppet-modulesync-configs directory and configure it for your need
|
# Step 4: Retrieve the puppet-modulesync-configs directory and configure it for your need
|
||||||
@ -136,6 +169,9 @@ else
|
|||||||
${GEM_HOME}/bin/bundle exec msync update --noop
|
${GEM_HOME}/bin/bundle exec msync update --noop
|
||||||
fi
|
fi
|
||||||
pushd modules/puppet-$proj
|
pushd modules/puppet-$proj
|
||||||
|
|
||||||
|
check_gerrit_user
|
||||||
|
|
||||||
md5password=`ruby -e "require 'digest/md5'; puts 'md5' + Digest::MD5.hexdigest('pw${proj}')"`
|
md5password=`ruby -e "require 'digest/md5'; puts 'md5' + Digest::MD5.hexdigest('pw${proj}')"`
|
||||||
sed -i "s/md5c530c33636c58ae83ca933f39319273e/${md5password}/g" spec/classes/${proj}_db_postgresql_spec.rb
|
sed -i "s/md5c530c33636c58ae83ca933f39319273e/${md5password}/g" spec/classes/${proj}_db_postgresql_spec.rb
|
||||||
git remote add gerrit ssh://$user@review.openstack.org:29418/openstack/puppet-$proj.git
|
git remote add gerrit ssh://$user@review.openstack.org:29418/openstack/puppet-$proj.git
|
||||||
@ -148,6 +184,8 @@ It has been automatically generated using cookiecutter[1] and msync[2]
|
|||||||
[2] https://github.com/openstack/puppet-modulesync-configs
|
[2] https://github.com/openstack/puppet-modulesync-configs
|
||||||
"
|
"
|
||||||
|
|
||||||
|
cleanup_gerrit_user
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
|
|
||||||
-----------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user