[Libreoffice-commits] core.git: logerrit

Michael Meeks michael.meeks at suse.com
Wed Mar 27 10:26:44 PDT 2013


 logerrit |   69 +++++++++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 54 insertions(+), 15 deletions(-)

New commits:
commit e8943d60fc2ffe2b3abd1195a53346aafb4a5a81
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Wed Mar 27 17:26:23 2013 +0000

    logerrit setup - automate lots more for first-time users.

diff --git a/logerrit b/logerrit
index 68bf2cc..9c7fdba 100755
--- a/logerrit
+++ b/logerrit
@@ -25,6 +25,19 @@ submit() {
         git push $GERRITURL HEAD:refs/$TYPE/$BRANCH
 }
 
+logerrit() {
+        echo "Host logerrit"
+        echo "    IdentityFile ~/.ssh/id_rsa"
+        echo "    User $1"
+        echo "    Port 29418"
+        echo "    HostName gerrit.libreoffice.org"
+        echo "Host gerrit.libreoffice.org"
+        echo "    IdentityFile ~/.ssh/id_rsa"
+        echo "    User $1"
+        echo "    Port 29418"
+        echo "    HostName gerrit.libreoffice.org"
+}
+
 case "$1" in
     help|--help|"")
         echo "Usage: ./logerrit subcommand [options]"
@@ -58,30 +71,56 @@ case "$1" in
     ;;
     setup)
         cd $(dirname $(readlink -f $0))
+	ssh_home="$HOME/.ssh";
+	ssh_key=
+	created_ssh=
+	if ! test -d $ssh_home; then
+	    echo "It appears that you have no ssh setup, running ssh-keygen to create that:"
+	    mkdir $ssh_home
+	    chmod 0700 $ssh_home
+	    created_ssh=TRUE
+	    echo
+	    echo "Hit enter to generate an ssh key - you will need to enter a pass-phrase"
+	    echo
+	    read
+	    ssh-keygen -t rsa -f "$ssh_home/id_rsa"
+	fi
+	if test -d $ssh_home; then
+	    if test -f "$ssh_home/id_rsa.pub"; then
+		ssh_key=`cat $ssh_home/id_rsa.pub`;
+	    elif test -f "$ssh_home/id_dsa.pub"; then
+		ssh_key=`cat $ssh_home/id_dsa.pub`;
+	    fi
+	fi
         echo "Please go to https://gerrit.libreoffice.org/ and:"
         echo "- press the 'register' button in the top right corner"
         echo "- after login set yourself a username (its recommended to use your IRC-nick)"
-        echo "- upload your public ssh-key."
+	if test "z$ssh_key" = "z"; then
+            echo "- add your public ssh-key into the ssh keys settings."
+	else
+	    echo "- paste the key below into the 'Add SSH Public Key' box."
+	    echo
+	    echo "$ssh_key"
+	    echo
+	fi
         echo
         echo "Note that you need to register additional email addresses, if you want to"
         echo "commit from them. Additional emails must be confirmed with repling to the"
         echo "invitation mail it sends you."
         echo
         read -p 'Which user name did you choose? ' GERRITUSER
-        echo
-        echo "Please now add the following to your ~/.ssh/config, creating the file if needed:"
-        echo
-        echo "Host logerrit"
-        echo "    IdentityFile ~/.ssh/id_rsa"
-        echo "    User $GERRIUSER"
-        echo "    Port 29418"
-        echo "    HostName gerrit.libreoffice.org"
-        echo "Host gerrit.libreoffice.org"
-        echo "    IdentityFile ~/.ssh/id_rsa"
-        echo "    User $GERRIUSER"
-        echo "    Port 29418"
-        echo "    HostName gerrit.libreoffice.org"
-        echo
+	if test "z$created_ssh" = "z"; then
+            echo
+            echo "Please now add the following to your ~/.ssh/config, creating the file if needed:"
+            echo
+	    logerrit $GERRITUSER
+            echo
+        else
+	    echo "Automatically creating your ssh config"
+	    (logerrit $GERRITUSER) > "$ssh_home/config"
+	fi
+	# setup the remote properly ...
+	git config remote.origin.pushurl ssh://logerrit/core
         echo "To see if your setup was successful, run './logerrit test' then."
         # a good place to make sure the hooks are set up
         ./g -z


More information about the Libreoffice-commits mailing list