This changeset fixes one of those "hard to find" errors you get in shell
scripts that turn out to be a single character fix. Sheesh. So in the 2
days I spent tracking down this bloody 1 char fix I also tidied up the
rest of the script and improved the UI a tad. Also fixed a couple of
other bugs that hadn't been discovered yet. :)
* contrib/git-for-steve.sh: Fix/improve quoting throughout.
Some UI improvements.
(set_aliases): Add missing ')'.
(set_keys): Grep for '^default-key' instead of 'default-key' in
gpg.conf in case it is commented out.
Signed-off-by: Steve Youngs <steve@sxemacs.org>
-**********************************************************************
+**[Welcome]***********************************************************
| Hello, and welcome to the SXEmacs Team |
| |
| This script will help guide you through setting up your personal |
| Hello, and welcome to the SXEmacs Team |
| |
| This script will help guide you through setting up your personal |
-**********************************************************************
+**[Dirty Tree]********************************************************
Your working directory contains changes that have not been committed
yet. Under certain conditions this script may do a couple of branch
jumps, so we will play it safe and store your changes out of the way
Your working directory contains changes that have not been committed
yet. Under certain conditions this script may do a couple of branch
jumps, so we will play it safe and store your changes out of the way
- echo "Please enter your name as you would like it to appear in the logs"
- echo -n "Take care to guard against shell expansion (\"John Doe\"): "
+ echo "Please enter your name as you would like it to appear in the logs"
+ echo -n 'Protected with quotes (e.g. "John Doe"): '
{
echo
echo "Git needs to know your email address (for commit logs, etc)."
{
echo
echo "Git needs to know your email address (for commit logs, etc)."
- echo -n "Please enter your email address (eg john@doe.com): "
+ echo -n "Please enter your email address (e.g. john@doe.com): "
read EMAIL
git config user.email ${EMAIL}
}
read EMAIL
git config user.email ${EMAIL}
}
if [ "${ORIGIN_URL}" != "http://git.sxemacs.org/sxemacs" ]; then
cat<<EOF
if [ "${ORIGIN_URL}" != "http://git.sxemacs.org/sxemacs" ]; then
cat<<EOF
-**********************************************************************
+**[Bad origin]********************************************************
WARNING: origin URL is WRONG.
It is currently set to: ${ORIGIN_URL}
WARNING: origin URL is WRONG.
It is currently set to: ${ORIGIN_URL}
- echo "**********************************************************************"
- echo "Setting up a \"for-steve\" branch to track origin/master."
+ echo "**[Tracking branch]***************************************************"
+ echo 'Setting up a "for-steve" branch to track origin/master.'
echo
echo "This is the branch that you will merge your work into once it is"
echo "ready for Steve to pull into his repo."
echo
echo "This is the branch that you will merge your work into once it is"
echo "ready for Steve to pull into his repo."
# Offer to leave them in for-steve, but only if we didn't stash
if [ ${LETSPOP} -eq 0 ]; then
echo
# Offer to leave them in for-steve, but only if we didn't stash
if [ ${LETSPOP} -eq 0 ]; then
echo
- echo -n "Switch to the \"for-steve\" branch when this script exits? [Y/n]: "
+ echo -n 'Switch to the "for-steve" branch when this script exits? [Y/n]: '
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
git checkout --quiet for-steve
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
git checkout --quiet for-steve
-**********************************************************************
+**[Remote]************************************************************
You need to have a remote repository set up for you to push your
changes to. Steve will need read-only access so he can fetch your
changes into his repo. You can name this repo anything you like,
You need to have a remote repository set up for you to push your
changes to. Steve will need read-only access so he can fetch your
changes into his repo. You can name this repo anything you like,
-just as long as it is a single word, and that word is not \"origin\".
+just as long as it is a single word, and that word is not "origin".
A remote repo can have a "Fetch URL", and a "Push URL". The
former (Fetch URL) is the URL from which people would clone, pull,
A remote repo can have a "Fetch URL", and a "Push URL". The
former (Fetch URL) is the URL from which people would clone, pull,
couple of examples...
ssh://user@example.com/~/path/to/repo (using ssh)
couple of examples...
ssh://user@example.com/~/path/to/repo (using ssh)
- https://user:pass@example.com/path/to/repo (using \"smart http\")
+ https://user:pass@example.com/path/to/repo (using "smart http")
+**********************************************************************
+-- more -- Hit [RETURN] to continue, or C-c to abort.
+EOF
+read junk
+
+ cat<<EOF
+**[Remote (cont)]*****************************************************
You _could_ use a git protocol URL (git://), but because the git
protocol has no authentication if you allow write access you are
allowing write access for anyone who has an internet connection. So
You _could_ use a git protocol URL (git://), but because the git
protocol has no authentication if you allow write access you are
allowing write access for anyone who has an internet connection. So
read junk
REMOTES=("$(git remote | grep -v origin)")
echo
read junk
REMOTES=("$(git remote | grep -v origin)")
echo
- echo "**********************************************************************"
+ echo "**[Remotes]***********************************************************"
echo " Currently configured remotes (possibly empty list)"
echo
for (( i = 1; i <= ${#REMOTES}; i++ )); do
echo " Currently configured remotes (possibly empty list)"
echo
for (( i = 1; i <= ${#REMOTES}; i++ )); do
done
echo
echo "**********************************************************************"
done
echo
echo "**********************************************************************"
- echo -n " Enter the number that corresponds to your remote, or \"x\" for none: "
+ echo -n ' Enter the number that corresponds to your remote, or "x" for none: '
read index
if [ "${index}" = "x" -o "${index}" = "" ]; then
echo
read index
if [ "${index}" = "x" -o "${index}" = "" ]; then
echo
- echo -n "Enter the \"Fetch URL\" (read-only access) to your remote: "
+ echo -n 'Enter the "Fetch URL" (read-only access) to your remote: '
- echo -n "Enter the \"Push URL\" (write-access for you) to your remote: "
+ echo -n 'Enter the "Push URL" (write-access for you) to your remote: '
- echo "And what would you like to call this remote? It MUST be a single "
- echo -n "word, and CANNOT be \"origin\": "
+ echo "And what would you like to call this remote? It MUST be a single"
+ echo -n 'word, and CANNOT be "origin": '
read MYREMOTE_NAME
git remote add ${MYREMOTE_NAME} ${MYREMOTE_FETCH}
git remote set-url --push ${MYREMOTE_NAME} ${MYREMOTE_PUSH}
read MYREMOTE_NAME
git remote add ${MYREMOTE_NAME} ${MYREMOTE_FETCH}
git remote set-url --push ${MYREMOTE_NAME} ${MYREMOTE_PUSH}
TYPE="X"
URL=$(git config remote.${REMOTES[${index}]}.url)
while [ "${TYPE}" != "F" -a "${TYPE}" != "P" -a "${TYPE}" != "B" ]; do
TYPE="X"
URL=$(git config remote.${REMOTES[${index}]}.url)
while [ "${TYPE}" != "F" -a "${TYPE}" != "P" -a "${TYPE}" != "B" ]; do
echo -n " used for Fetch, Push, or Both? [F/P/B]: "
read TYPE
TYPE=$(echo ${TYPE}|tr 'fpb' 'FPB')
done
case ${TYPE} in
F)
echo -n " used for Fetch, Push, or Both? [F/P/B]: "
read TYPE
TYPE=$(echo ${TYPE}|tr 'fpb' 'FPB')
done
case ${TYPE} in
F)
- echo -n "${REMOTES[${index}]} \"Push URL\" (write-access for you): "
+ echo -n ${REMOTES[${index}]} '"Push URL" (write-access for you): '
read TYPEURL
git remote set-url --push ${REMOTES[${index}]} ${TYPEURL}
;;
P)
read TYPEURL
git remote set-url --push ${REMOTES[${index}]} ${TYPEURL}
;;
P)
- echo -n "${REMOTES[${index}]} \"Fetch URL\" (read-only access): "
+ echo -n ${REMOTES[${index}]} '"Fetch URL" (read-only access): '
read TYPEURL
git remote set-url ${REMOTES[${index}]} ${TYPEURL}
git remote set-url --push ${REMOTES[${index}]} ${URL}
read TYPEURL
git remote set-url ${REMOTES[${index}]} ${TYPEURL}
git remote set-url --push ${REMOTES[${index}]} ${URL}
if [ -z "$(git config sxemacs.remote)" ]; then
cat<<EOF
if [ -z "$(git config sxemacs.remote)" ]; then
cat<<EOF
-**********************************************************************
+**[Public repo]*******************************************************
The easiest, and quickest way to get your work and changes into the
main SXEmacs repository is if you have a publicly accessible remote
repo. Well, technically, it does not need to be publicly accessible,
The easiest, and quickest way to get your work and changes into the
main SXEmacs repository is if you have a publicly accessible remote
repo. Well, technically, it does not need to be publicly accessible,
will ever need to write to this repo.
**********************************************************************
EOF
will ever need to write to this repo.
**********************************************************************
EOF
- echo -n " Do you have a remote repo like this set up? [Y/n]:"
+ echo -n " Do you have a remote repo like this set up? [Y/n]: "
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
set_myremote
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
set_myremote
git tag|grep -q ${TAGNAME} && TAGEXISTS=yes
if [ "${TAGEXISTS}" = "yes" ]; then
git tag|grep -q ${TAGNAME} && TAGEXISTS=yes
if [ "${TAGEXISTS}" = "yes" ]; then
+ echo
+ echo "**[Existing devkey]***************************************************"
echo "There is already a developer key tag using your initials..."
echo
git show ${TAGNAME}|sed -n 2,5p
echo
echo "There is already a developer key tag using your initials..."
echo
git show ${TAGNAME}|sed -n 2,5p
echo
- echo -n "Is it yours? [Y/n]: "
+ echo "**********************************************************************"
+ echo -n " Is it yours? [Y/n]: "
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
git config sxemacs.devkey $(git show-ref ${TAGNAME}|awk '{print $1;}')
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
git config sxemacs.devkey $(git show-ref ${TAGNAME}|awk '{print $1;}')
To verify signed objects in the repo, use the '--show-signature'
option with the git-log and git-show commands.
To verify signed objects in the repo, use the '--show-signature'
option with the git-log and git-show commands.
+To verify this tag, use 'git tag -v ${TAGNAME}'
+
EOF
)
git tag -s ${TAGNAME} -m "${TAGMSG}" \
EOF
)
git tag -s ${TAGNAME} -m "${TAGMSG}" \
git config sxemacs.devkey $(git show-ref ${TAGNAME} |
awk '{print $1;}')
git config sxemacs.devkey $(git show-ref ${TAGNAME} |
awk '{print $1;}')
- echo
- echo "Your devkey tag has been created successfully."
+ # If something went wrong here we should probably bail out
+ if [ $? -gt 0 ]; then
+ echo 1>&2 'Something has gone horribly wrong while trying to add your devkey.'
+ echo 1>&2 'Please check that your local GnuPG settings are correct, and then'
+ echo 1>&2 'attempt to re-run this script.'
+ echo
+ echo 1>&2 'If the problem persists, get in contact with us and we will do our'
+ echo 1>&2 'best to help you resolve it.'
+ exit 1
+ else
+ echo
+ echo "Your devkey tag has been created successfully."
+ fi
echo -n "Can we now push ${TAGNAME} to $(git config sxemacs.remote)? [Y/n]: "
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
git push $(git config sxemacs.remote) ${TAGNAME}
cat<<EOF
echo -n "Can we now push ${TAGNAME} to $(git config sxemacs.remote)? [Y/n]: "
read RESP
if [ "${RESP}" = "Y" -o "${RESP}" = "y" -o "${RESP}" = "" ]; then
git push $(git config sxemacs.remote) ${TAGNAME}
cat<<EOF
-**********************************************************************
+**[Devkey]************************************************************
Please let Steve know that your devkey is ready to be fetched into the
main SXEmacs repo.
Please let Steve know that your devkey is ready to be fetched into the
main SXEmacs repo.
git tag|grep -q maintainer-pgp &&
git show maintainer-pgp|gpg --import --quiet
git tag|grep -q maintainer-pgp &&
git show maintainer-pgp|gpg --import --quiet
- DEFKEY=$(grep default-key ~/.gnupg/gpg.conf 2>/dev/null |
+ DEFKEY=$(grep '^default-key' ~/.gnupg/gpg.conf 2>/dev/null |
awk '{print $2;}')
if [ -z "${DEFKEY}" ]; then
GUESS=$(gpg --list-keys $(git config user.email) |
awk '{print $2;}')
if [ -z "${DEFKEY}" ]; then
GUESS=$(gpg --list-keys $(git config user.email) |
if ! type gpg 1>/dev/null ; then
cat<<EOF
if ! type gpg 1>/dev/null ; then
cat<<EOF
-**********************************************************************
+**[No GnuPG]**********************************************************
WARNING: We could not find a gpg executable!
The GnuPG related setup in this script will be skipped.
WARNING: We could not find a gpg executable!
The GnuPG related setup in this script will be skipped.
"SXEmacs Patches <sxemacs-patches@sxemacs.org>"
[ -n "$(git config format.subjectprefix)" ] ||
git config format.subjectprefix Patch
"SXEmacs Patches <sxemacs-patches@sxemacs.org>"
[ -n "$(git config format.subjectprefix)" ] ||
git config format.subjectprefix Patch
- git config format.headers || git config format.headers \
+ [ -n "$(git config format.headers)" ] || git config format.headers \
"X-Git-Repo: $(git config remote.$(git config sxemacs.remote).url)
X-Git-Branch: for-steve"
[ -n "$(git config sendemail.to)" ] || git config sendemail.to \
"X-Git-Repo: $(git config remote.$(git config sxemacs.remote).url)
X-Git-Branch: for-steve"
[ -n "$(git config sendemail.to)" ] || git config sendemail.to \
"$(git config user.name) <$(git config user.email)>"
echo
"$(git config user.name) <$(git config user.email)>"
echo
- echo "**********************************************************************"
+ echo "**[Format Summary]****************************************************"
echo " Here are the format and sendemail configs we just set."
echo
echo " format.numbered --" $(git config format.numbered)
echo " Here are the format and sendemail configs we just set."
echo
echo " format.numbered --" $(git config format.numbered)
}
BOOL=$(git config sxemacs.formats)
if [ "${BOOL}" != "true" ]; then
}
BOOL=$(git config sxemacs.formats)
if [ "${BOOL}" != "true" ]; then
- echo
- echo "We're going to set some format config values, but only if they aren't"
- echo "already set, so your existing ones are safe."
+ cat<<EOF
+
+**[Formats]***********************************************************
+We are going to set some format config values, but only if they are
+not already set, so your existing ones are safe.
+**********************************************************************
+ Hit [RETURN] to continue, or C-c to abort.
+EOF
+ read junk
{
# post-commit hook
if [ -f ".git/hooks/post-commit" ]; then
{
# post-commit hook
if [ -f ".git/hooks/post-commit" ]; then
- cat>>.git/hooks/post-commit<<EOF
+ if ! grep -q 'lines added by git-for-steve' .git/hooks/post-commit; then
+ cat>>.git/hooks/post-commit<<EOF
### Begin - lines added by git-for-steve.sh
LOG=\$(git rev-parse --show-toplevel)/++log
[ -f \${LOG} ] && rm -f \${LOG}
### End -- lines added by git-for-steve.sh
EOF
### Begin - lines added by git-for-steve.sh
LOG=\$(git rev-parse --show-toplevel)/++log
[ -f \${LOG} ] && rm -f \${LOG}
### End -- lines added by git-for-steve.sh
EOF
elif [ -f ".git/hooks/post-commit.sample" ]; then
elif [ -f ".git/hooks/post-commit.sample" ]; then
- cat>>.git/hooks/post-commit.sample<<EOF
+ cp .git/hooks/post-commit{.sample,}
+ sed -i /Nothing/d .git/hooks/post-commit
+ cat>>.git/hooks/post-commit<<EOF
### Begin - lines added by git-for-steve.sh
LOG=\$(git rev-parse --show-toplevel)/++log
[ -f \${LOG} ] && rm -f \${LOG}
### End -- lines added by git-for-steve.sh
EOF
### Begin - lines added by git-for-steve.sh
LOG=\$(git rev-parse --show-toplevel)/++log
[ -f \${LOG} ] && rm -f \${LOG}
### End -- lines added by git-for-steve.sh
EOF
- sed -i /Nothing/d .git/hooks/post-commit.sample
- mv .git/hooks/post-commit{.sample,}
else
cat>.git/hooks/post-commit<<EOF
#!/bin/sh
else
cat>.git/hooks/post-commit<<EOF
#!/bin/sh
if [ "${HAVEHOOK}" != "true" ]; then
cat<<EOF
if [ "${HAVEHOOK}" != "true" ]; then
cat<<EOF
-**********************************************************************
+**[Commit Hook]*******************************************************
Some of the SXEmacs developers use a variation of the
Some of the SXEmacs developers use a variation of the
-#'add-change-log-entry defun (C-x 4 a) for logging their changes
+'add-change-log-entry' defun (C-x 4 a) for logging their changes
It creates a log file in the toplevel directory (called '++log') which
you can use with the '-F' switch of 'git commit'.
It creates a log file in the toplevel directory (called '++log') which
you can use with the '-F' switch of 'git commit'.
[ -n "$(git config alias.cob)" ] || git config alias.cob "checkout -b"
[ -n "$(git config alias.ci)" ] || git config alias.ci commit
[ -n "$(git config alias.cam)" ] || git config alias.cam "commit -sam"
[ -n "$(git config alias.cob)" ] || git config alias.cob "checkout -b"
[ -n "$(git config alias.ci)" ] || git config alias.ci commit
[ -n "$(git config alias.cam)" ] || git config alias.cam "commit -sam"
+ [ -n "$(git config alias.sam)" ] || git config alias.sam "commit -sam"
BOOL=$(git config sxemacs.commithook)
if [ "${BOOL}" = "true" ]; then
BOOL=$(git config sxemacs.commithook)
if [ "${BOOL}" = "true" ]; then
[ -n "$(git config alias.rbi)" ] || git config alias.rbi "rebase -i"
[ -n "$(git config alias.prb)" ] || git config alias.prb "pull --rebase"
[ -n "$(git config alias.rbi)" ] || git config alias.rbi "rebase -i"
[ -n "$(git config alias.prb)" ] || git config alias.prb "pull --rebase"
- [ -n "$(git config alias.pfs)" ] ||
- git config alias.pfs "push $(git config sxemacs.remote) for-steve"
+
+ REMOTE=$(git config sxemacs.remote)
+ if [ -n "${REMOTE}" ]; then
+ [ -n "$(git config alias.pfs)" ] ||
+ git config alias.pfs "push ${REMOTE} for-steve"
+ fi
+
[ -n "$(git config alias.fp)" ] || git config alias.fp \
"format-patch --minimal -o ${GITTMP} origin/master"
[ -n "$(git config alias.fpc)" ] || git config alias.fpc \
[ -n "$(git config alias.fp)" ] || git config alias.fp \
"format-patch --minimal -o ${GITTMP} origin/master"
[ -n "$(git config alias.fpc)" ] || git config alias.fpc \
"send-email ${GITTMP}"
[ -n "$(git config alias.spc)" ] || git config alias.spc \
"send-email --compose ${GITTMP}"
"send-email ${GITTMP}"
[ -n "$(git config alias.spc)" ] || git config alias.spc \
"send-email --compose ${GITTMP}"
- [ -n "$(git config alias.wb" ] || git config alias.wb \
+ [ -n "$(git config alias.wb)" ] || git config alias.wb \
"rev-parse --abbrev-ref HEAD"
echo
"rev-parse --abbrev-ref HEAD"
echo
- echo "**********************************************************************"
+ echo "**[Your Aliases]******************************************************"
echo " The following aliases are now available for use..."
echo
git alias
echo " The following aliases are now available for use..."
echo
git alias
if [ "${BOOL}" != "true" ]; then
cat<<EOF
if [ "${BOOL}" != "true" ]; then
cat<<EOF
-**********************************************************************
+**[Aliases]***********************************************************
And finally, lets set a few aliases. We will only set them if they
have not already been set so all of your pre-existing aliases are
safe.
And finally, lets set a few aliases. We will only set them if they
have not already been set so all of your pre-existing aliases are
safe.
## All done, bar the shouting...
cat<<EOF
## All done, bar the shouting...
cat<<EOF
-**********************************************************************
+**[Thanks]************************************************************
| Thank you for taking the time to setup your repo so that you can |
| contribute back to the SXEmacs Project. We really appreciate all |
| that you do, no matter how small or insignificant you may think it |
| Thank you for taking the time to setup your repo so that you can |
| contribute back to the SXEmacs Project. We really appreciate all |
| that you do, no matter how small or insignificant you may think it |