diff options
-rw-r--r-- | linaropy/git/gitrepo.py | 27 | ||||
-rw-r--r-- | linaropy/rn/gccclone.py | 2 | ||||
-rw-r--r-- | linaropy/rn/rngen.py | 6 |
3 files changed, 13 insertions, 22 deletions
diff --git a/linaropy/git/gitrepo.py b/linaropy/git/gitrepo.py index 78fcefb..a1f5bd9 100644 --- a/linaropy/git/gitrepo.py +++ b/linaropy/git/gitrepo.py @@ -68,11 +68,9 @@ class GitRepo(object): def getbranch(self): try: with cd(self.repodir): - branch = git("rev-parse", "--abbrev-ref", - "HEAD").stdout.rstrip() + return git("rev-parse", "--abbrev-ref", "HEAD").rstrip() except ErrorReturnCode: raise EnvironmentError("Unable to get the current branch") - return str(branch, 'utf-8') # TODO make this a bit more sophisticated because the user might not be # using 'origin' as their remote name. @@ -90,14 +88,13 @@ class GitRepo(object): stashid = "" try: - self.prevbranch = git( - "rev-parse", "--abbrev-ref", "HEAD").stdout.rstrip() + self.prevbranch = git("rev-parse", "--abbrev-ref", "HEAD") except ErrorReturnCode: raise EnvironmentError("Unable to get the current branch") try: # TODO: do we want to do a blanket git add *? - stashid = git("stash", "create").stdout.rstrip() + stashid = git("stash", "create") # If there's no stash then there's no reason to save. if stashid: git("stash", "save") @@ -113,7 +110,7 @@ class GitRepo(object): except ErrorReturnCode: try: # if it doesn't exist we need to checkout a new branch - git("checkout", "-b", branch, track).stdout.rstrip() + git("checkout", "-b", branch, track) except ErrorReturnCode as exc: raise EnvironmentError( "Unable to checkout -b %s %s" % (branch, track)) @@ -187,9 +184,10 @@ class GitRepo(object): try: with cd(self.repodir): if oneline: - print(git("log", "--oneline", "-n %d" % numcommits)) + print(git("--no-pager", "log", "--oneline", "-n %d" % + numcommits)) else: - print(git("log", "-n %d" % numcommits)) + print(git("--no-pager", "log", "-n %d" % numcommits)) except ErrorReturnCode: raise EnvironmentError("Unable to git log -n %d" % numcommits) @@ -199,11 +197,10 @@ class GitRepo(object): try: with cd(self.repodir): if versus is not None: - return git("rev-list", "%s..%s" % (versus, - branch)).stdout.rstrip() + return git("rev-list", "%s..%s" % (versus, branch)).rstrip() else: return git("rev-list", branch, "--max-count=%d" % - numcommits).stdout.rstrip() + numcommits).rstrip() except ErrorReturnCode as exc: raise EnvironmentError("Unable to git rev-list because: %s" % (numcommits, str(exc))) @@ -264,9 +261,8 @@ class TestGitRepo(unittest.TestCase): # Helper function used in some of the tests (e.g. for delete_branch). We # use this instead of the equivalent GitRepo::getbranch so we can test # different GitRepo functionality independently. - branch = str(git("rev-parse", "--abbrev-ref", "HEAD")) # git rev-parse returns a trailing newline that we must get rid of - return branch[:-1] + return git("rev-parse", "--abbrev-ref", "HEAD").rstrip() # This class is only used to test the GitRepo functions since, as an, # abstract-baseclass, GitRepo doesn't define repodir, and we need an @@ -321,8 +317,7 @@ class TestGitRepo(unittest.TestCase): def test_getbranch(self): with cd(self.dgr.repodir): try: - git("checkout", "-b", "master_test", - "origin/master").stdout.rstrip() + git("checkout", "-b", "master_test", "origin/master") except ErrorReturnCode as exc: raise EnvironmentError( "Unable to checkout -b %s %s" % (branch, track)) diff --git a/linaropy/rn/gccclone.py b/linaropy/rn/gccclone.py index bd82ebf..79e500a 100644 --- a/linaropy/rn/gccclone.py +++ b/linaropy/rn/gccclone.py @@ -18,7 +18,7 @@ class GCCClone(Clone): except: raise IOError('gcc/BASE-VER not found in ' + clonedir) - log = git("log", "-n 1", "--grep=Merge branch") + log = git("--no-pager", "log", "-n 1", "--grep=Merge branch") for logline in log: if logline.lstrip().startswith("Merge"): # For some reason rsplit('.') isn't working. diff --git a/linaropy/rn/rngen.py b/linaropy/rn/rngen.py index 7daae9e..90a44f6 100644 --- a/linaropy/rn/rngen.py +++ b/linaropy/rn/rngen.py @@ -135,7 +135,7 @@ def rngen(rn_series, gccclone, history): # Verify that the basis url is actually valid, otherwise the release notes # will contain erroneous information. - url = urllib2 + url = urllib try: ret = urllib.request.urlopen(basis_url) except url.URLError as e: @@ -226,8 +226,6 @@ def rngen(rn_series, gccclone, history): major=ver['major'], minor=ver['minor']) - source_textile_rendering = source_textile_rendering.encode('utf-8') - out_source = '' + outfile out_binary = 'Linaro-' + outfile @@ -269,7 +267,6 @@ def rngen(rn_series, gccclone, history): stab_maint=stab_maint, snap_rc_release=release_type) - binary_textile_rendering = binary_textile_rendering.encode('utf-8') try: with open(out_binary + '.textile', 'w') as f: f.write(binary_textile_rendering) @@ -308,7 +305,6 @@ def rngen(rn_series, gccclone, history): stab_maint=stab_maint, snap_rc_release=release_type) - announce_rendering = announce_rendering.encode('utf-8') announce_file = 'announce-' + out_binary + '.txt' try: with open(announce_file, 'w') as f: |