Skip to content

Commit

Permalink
fixed "ck add repo --zip" if zip contains Git repository (making it s…
Browse files Browse the repository at this point in the history
…hared)
  • Loading branch information
gfursin committed Sep 24, 2018
1 parent a138b47 commit 0e5ce3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* fixed minor bug in "ck rm" when deleting entries only from allowed repos (for crowdsourcing)
* fixed problem with wrong repo UID when repo is installed from zip archive
* added flag --all to "ck zip" to archive all files including .git
* fixed "ck add repo --zip" if zip contains Git repository (making it shared)

* V1.9.5
* added "debug":"yes" to kernel for GitHub versions
Expand Down
28 changes: 19 additions & 9 deletions ck/repo/module/repo/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ def add(i):

overwrite=i.get('overwrite','')

remote=i.get('remote','')
rruoa=i.get('remote_repo_uoa','')
shared=i.get('shared','')
if shared=='yes': shared='git'

share=i.get('share','')
if share=='yes' and shared=='': shared='git'

ptr=''
zp=i.get('zip','')
gz=i.get('gitzip','')
Expand All @@ -159,6 +167,10 @@ def add(i):

try:
with zipfile.ZipFile(zp) as z:
zip_has_git=False
if '.git/HEAD' in z.namelist():
zip_has_git=True

if ck.cfg['repo_file'] in z.namelist():
x=z.open(ck.cfg['repo_file'])
y=x.read()
Expand All @@ -171,6 +183,12 @@ def add(i):
di=yd.get('data_uid','')
dn=yd.get('data_name','')

zip_shared=yd.get('dict',{}).get('shared','')
if zip_shared!='':
if zip_shared!='git' or zip_has_git:
shared=yd['dict']['shared']
share='yes'

x.close()
z.close()
except Exception as e:
Expand All @@ -190,14 +208,6 @@ def add(i):
ptr=d+'-master/'
quiet='yes'

remote=i.get('remote','')
rruoa=i.get('remote_repo_uoa','')
shared=i.get('shared','')
if shared=='yes': shared='git'

share=i.get('share','')
if share=='yes' and shared=='': shared='git'

rx=form_url(i)
if rx['return']>0: return rx
url=rx['url']
Expand Down Expand Up @@ -385,7 +395,7 @@ def add(i):
# If git, clone repo
repo_had_local=True
dd={}
if remote!='yes' and shared=='git':
if remote!='yes' and shared=='git' and zp=='':
r=pull({'path':p, 'type':shared, 'url':url, 'clone':'yes', 'git':i.get('git',''), 'out':o})
if r['return']>0: return r

Expand Down

0 comments on commit 0e5ce3b

Please sign in to comment.