diff --git a/CHANGES.txt b/CHANGES.txt index 12bb9b7c82..f61b1bd433 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -2,6 +2,7 @@ * fixed issue #80 (adding zip repo if starts with ~) * fixed issue #81 (when renaming entry with data_name==data_alias, change it to the new alias) * added flag --name (duplicate of --show_name) to "ck ls" + * fixed issue #82 (detecting name of repo from the zip filename) * V1.9.2 * added "ck cd {CK entry}" to open a new shell in a given CK entry diff --git a/ck/repo/module/repo/module.py b/ck/repo/module/repo/module.py index 51c69deb07..e88e347c9c 100644 --- a/ck/repo/module/repo/module.py +++ b/ck/repo/module/repo/module.py @@ -159,22 +159,32 @@ def add(i): try: with zipfile.ZipFile(zp) as z: - x=z.open(ck.cfg['repo_file']) - y=x.read() + if ck.cfg['repo_file'] in z.namelist(): + x=z.open(ck.cfg['repo_file']) + y=x.read() - r=ck.convert_json_str_to_dict({'str':y, 'skip_quote_replacement':'yes'}) - if r['return']>0: return r - yd=r['dict'] + r=ck.convert_json_str_to_dict({'str':y, 'skip_quote_replacement':'yes'}) + if r['return']>0: return r + yd=r['dict'] - d=yd.get('data_uoa','') - di=yd.get('data_uid','') - dn=yd.get('data_name','') + d=yd.get('data_uoa','') + di=yd.get('data_uid','') + dn=yd.get('data_name','') - x.close() + x.close() z.close() except Exception as e: return {'return':1, 'error':'problem reading zip file ('+format(e)+')'} + if d=='': + x1=os.path.basename(zp) + d=os.path.splitext(x1)[0] + if d.startswith('ckr-'): + d=d[4:] + + if o=='con': + ck.out('Auto-detected repo name from zip filename: '+d) + if gz=='yes': zp=ck.cfg['default_shared_repo_url']+'/'+d+'/archive/master.zip' ptr=d+'-master/'