xxxrac / git-repo

Automatically exported from code.google.com/p/git-repo
Apache License 2.0
0 stars 0 forks source link

Cannot parse git version number like "1.8.4-rc1" #146

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Affected Version: 1.19
Environment: Linux

What steps will reproduce the problem?
1. Install git version 1.8.4-rc1
2. Copy repo executable
3. Execute "repo" or "repo init"

File "/users/fparrel/bin/repo", line 279, in _CheckGitVersion
    ver_act = tuple(map(int, ver_str.split('.')[0:3]))
ValueError: invalid literal for int() with base 10: '4-rc1'

Fix:
----

use new function:

def inthyphenproof(s):
    if '-' in s:
        return int(s[:s.find('-')])
    else:
        return int(s)

    ver_act = tuple(map(inthyphenproof, ver_str.split('.')[0:3]))

Original issue reported on code.google.com by frederic...@gmail.com on 5 Aug 2013 at 3:09

GoogleCodeExporter commented 9 years ago
Just ran into this issue, would appreciate a fix:

Here's a patch.

diff --git a/repo b/repo
index eeb8920..db1fef3 100755
--- a/repo
+++ b/repo
@@ -296,7 +296,7 @@ def _CheckGitVersion():
     raise CloneFailure()

   ver_str = ver_str[len('git version '):].strip()
-  ver_act = tuple(map(int, ver_str.split('.')[0:3]))
+  ver_act = tuple(map(int, ver_str.split('-')[0].split('.')[0:3]))
   if ver_act < MIN_GIT_VERSION:
     need = '.'.join(map(str, MIN_GIT_VERSION))
     _print('fatal: git %s or later required' % need, file=sys.stderr)

Original comment by thomas.s...@googlemail.com on 12 Oct 2013 at 12:47

GoogleCodeExporter commented 9 years ago
Fixed by v1.12.12.

https://gerrit-review.googlesource.com/54163
https://gerrit-review.googlesource.com/54171

Original comment by jrn@google.com on 2 Feb 2014 at 8:48

GoogleCodeExporter commented 9 years ago
The fix works for version strings with hyphens, but (as of today) the latest 
git version in Debian unstable has a version string like this:

% git --version
git version 1.9.rc1

A possible fix is:

diff --git a/git_command.py b/git_command.py
index d347dd6..e18f07f 100644
--- a/git_command.py
+++ b/git_command.py
@@ -90,7 +90,7 @@ class _GitCall(object):
       if ver_str.startswith('git version '):
         _git_version = tuple(
           map(int,
-            ver_str[len('git version '):].strip().split('-')[0].split('.')[0:3]
+            ver_str[len('git version 
'):].strip().split('-')[0].split('.rc')[0].split('.')[0:3]
           ))
       else:
         print('fatal: "%s" unsupported' % ver_str, file=sys.stderr)

Original comment by devrin.t...@gmail.com on 3 Feb 2014 at 2:25

GoogleCodeExporter commented 9 years ago
Should have checked with the latest repo version available.  It works for me as 
of v1.12.13.

Original comment by devrin.t...@gmail.com on 3 Feb 2014 at 2:36