Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
解决了Python3下代码拉取bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BlBana committed Mar 26, 2018
1 parent 41add93 commit 306fbd4
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cobra/pickup.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,10 @@ def clone(self):

p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
(clone_out, clone_err) = p.communicate()

clone_out = clone_out.decode('utf-8')
clone_err = clone_err.decode('utf-8')

clone_err = clone_err.replace('{0}:{1}'.format(self.repo_username, self.repo_password), '')

logger.debug('[PICKUP] [CLONE] ' + clone_out.strip())
Expand Down Expand Up @@ -421,6 +425,10 @@ def diff(self, new_version, old_version, raw_output=False):
cmd = 'git diff ' + old_version + ' ' + new_version
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
(diff_out, diff_err) = p.communicate()

diff_out = diff_out.decode('utf-8')
diff_err = diff_err.decode('utf-8')

logger.info(diff_out)

# change the work directory back.
Expand Down Expand Up @@ -448,6 +456,10 @@ def checkout(self, branch):
cmd = "git fetch origin && git checkout " + branch
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
(checkout_out, checkout_err) = p.communicate()

checkout_out = checkout_out.decode('utf-8')
checkout_err = checkout_err.decode('utf-8')

logger.info('[PICKUP] [CHECKOUT] ' + checkout_err.strip())

# Already on
Expand Down Expand Up @@ -572,6 +584,10 @@ def __init__(self, filename, current_version=None, online_version=None):
)
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
(diff_out, diff_err) = p.communicate()

diff_out = diff_out.decode('utf-8')
diff_err = diff_err.decode('utf-8')

if len(diff_err) == 0:
logger.debug("[PICKUP] svn diff success")
elif 'authorization failed' in diff_err:
Expand All @@ -589,6 +605,8 @@ def log(self):
)
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
log_out = p.communicate()[0]
log_out = log_out.decode('utf-8')

return log_out

def diff(self):
Expand All @@ -601,6 +619,7 @@ def diff(self):
)
p = subprocess.Popen(cmd, shell=True, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
diff_out = p.communicate()[0]
diff_out = diff_out.decode('utf-8')

added, removed, changed = [], [], []
diff = {}
Expand Down

0 comments on commit 306fbd4

Please sign in to comment.