You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gump.apache.org by bo...@apache.org on 2009/02/26 05:38:16 UTC

svn commit: r748010 - /gump/trunk/python/gump/core/update/git.py

Author: bodewig
Date: Thu Feb 26 04:38:16 2009
New Revision: 748010

URL: http://svn.apache.org/viewvc?rev=748010&view=rev
Log:
make git detect "bad" working copies

Modified:
    gump/trunk/python/gump/core/update/git.py

Modified: gump/trunk/python/gump/core/update/git.py
URL: http://svn.apache.org/viewvc/gump/trunk/python/gump/core/update/git.py?rev=748010&r1=748009&r2=748010&view=diff
==============================================================================
--- gump/trunk/python/gump/core/update/git.py (original)
+++ gump/trunk/python/gump/core/update/git.py Thu Feb 26 04:38:16 2009
@@ -17,8 +17,10 @@
 # limitations under the License.
 
 from gump import log
-from gump.core.model.workspace import Cmd
 from gump.core.update.scmupdater import ScmUpdater, should_be_quiet
+from gump.util.process.command import Cmd
+from gump.util.process.launcher import execute
+from gump.util.tools import tailFileToString
 
 def log_repository_and_url(module):
     repository = module.repository
@@ -65,3 +67,29 @@
                   module.getSourceControlStagingDirectory())
         maybe_make_quiet(module, cmd)
         return cmd
+
+    def workspaceMatchesModule(self, module):
+        """
+            Run git config remote.origin.url to see whether the URL matches
+        """
+        cmd = Cmd('git', 'check_workspace_' + module.getName(), 
+                  module.getSourceControlStagingDirectory())
+        cmd.addParameter('config')
+        cmd.addParameter('remote.origin.url')
+
+        result = execute(cmd)
+
+        output = None
+        if result.hasOutput():
+            output = tailFileToString(result.getOutput(), 1).rstrip()
+
+        if not result.isOk():
+            return (False, 'git config returned ' + str(result.exit_code))
+
+        elif not output:
+            return (False, 'git config didn\'t return any output.')
+
+        expectedURL = module.getScm().getRootUrl()
+
+        return (expectedURL == output, 'Expected URL \'' + expectedURL + \
+                    '\' but working copy was \'' + output + '\'')