fix bug# PTINF-43, get project name failure if not in remote.origin
authorHasan Wan <hasan.wan@intel.com>
Wed, 18 Jan 2012 03:29:52 +0000 (11:29 +0800)
committerHasan Wan <hasan.wan@intel.com>
Wed, 18 Jan 2012 03:29:52 +0000 (11:29 +0800)
data/build.sh
data/import.sh
data/packaging.sh

index 7873f9b..35cc068 100644 (file)
@@ -47,15 +47,22 @@ git branch -a|sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'|grep "release" > /dev/null 2
 
 git status|grep "modified">/dev/null 2>&1 &&echo "Warning: Uncommited local changes found.  Sending local changes to build remotely. "
 
-# Get project name from git url
-git_url=`git config remote.origin.url`
-echo $git_url|grep ^ssh > /dev/null
-if [ $? == 0 ]; then
-    prj_name=`basename $git_url`
-else
-    prj_name=$(echo $git_url|cut -d ':' -f2)
+# If project name is set in gitbuildsystem.project, use it, else use the default remote.origin.url
+prj_name=$(git config gitbuildsystem.project)
+if [ -z "$prj_name" ]; then
+
+    git_url=`git config remote.origin.url`
+    echo $git_url|grep ^ssh > /dev/null
+    if [ $? == 0 ]; then
+        prj_name=$(echo $git_url|sed 's/ssh\:.*\:[0-9]*\/\(.*\)/\1/')
+    else
+        prj_name=$(echo $git_url|cut -d ':' -f2)
+    fi
+    
 fi
 
+[ -z "$prj_name" ] && die "Can't find the project name, you might need 'git config --add gitbuildsystem.project <project-name>' to set it."
+
 # tar the local changes
 tar jcf package.tar.bz2 `git ls-files`
 
index 0680747..22e0ba7 100644 (file)
@@ -60,13 +60,16 @@ passwdx=$(gbs cfg passwdx)
 source_tarball_name=$(basename $source_tarball)
 
 if [ -z "$target_project" ]; then
-# Get project name from git url
-    git_url=`git config remote.origin.url`
-    echo $git_url|grep ^ssh > /dev/null
-    if [ $? == 0 ]; then
-        target_project=`basename $git_url`
-    else
-        target_project=$(echo $git_url|cut -d ':' -f2)
+    # If project name is set in gitbuildsystem.project, use it, else use the default remote.origin.url
+    target_project=$(git config gitbuildsystem.project)
+    if [ -z "$target_project" ]; then
+        git_url=`git config remote.origin.url`
+        echo $git_url|grep ^ssh > /dev/null
+        if [ $? == 0 ]; then
+            target_project=$(echo $git_url|sed 's/ssh\:.*\:[0-9]*\/\(.*\)/\1/')
+        else
+            target_project=$(echo $git_url|cut -d ':' -f2)
+        fi
     fi
 fi
 
index f999ebf..5fc431c 100644 (file)
@@ -320,14 +320,22 @@ user=$(gbs cfg user)
 passwd=$(gbs cfg passwd)
 HUDSON_SERVER=$(gbs cfg src_server)
 
-git_url=`git config remote.origin.url`
-echo $git_url|grep ^ssh  > /dev/null
-if [ $? == 0 ]; then
-    project=`basename $git_url`
-else
-    project=$(echo $git_url|cut -d ':' -f2)
+# If project name is set in gitbuildsystem.project, use it, else use the default remote.origin.url
+project=$(git config gitbuildsystem.project)
+if [ -z "$project" ]; then
+
+    git_url=`git config remote.origin.url`
+    echo $git_url|grep ^ssh > /dev/null
+    if [ $? == 0 ]; then
+        project=$(echo $git_url|sed 's/ssh\:.*\:[0-9]*\/\(.*\)/\1/')
+    else
+        project=$(echo $git_url|cut -d ':' -f2)
+    fi
+    
 fi
 
+[ -z "$project" ] && die "Can't find the project name, you might need 'git config --add gitbuildsystem.project <project-name>' to set it."
+
 info_msg "Packaging for major release ${tag}"
 srctar_md5sum=""
 get_srctar_md5sum $version $project $commitid