Skip to content

Commit 1297332

Browse files
authored
Merge pull request #275 from screamerbg/development
mbed CLI 0.8.x fixes
2 parents af115ae + 3fd84a8 commit 1297332

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

mbed/mbed.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636

3737
# Application version
38-
ver = '0.8.3'
38+
ver = '0.8.5'
3939

4040
# Default paths to Mercurial and Git
4141
hg_cmd = 'hg'
@@ -1454,15 +1454,24 @@ def thunk(parsed_args):
14541454
def new(name, scm='git', program=False, library=False, mbedlib=False, create_only=False, depth=None, protocol=None):
14551455
global cwd_root
14561456

1457-
d_path = name or os.getcwd()
1458-
p_path = Repo.findparent(d_path) or d_path
1457+
d_path = os.path.abspath(name or os.getcwd())
1458+
p_path = os.path.dirname(d_path)
14591459
if program and library:
14601460
error("Cannot use both --program and --library options.", 1)
14611461
elif program or library:
14621462
d_type = 'library' if library else 'program'
14631463
else:
1464+
pp = Program(p_path)
1465+
pd = Program(d_path)
1466+
if pp.path == pd.path:
1467+
d_type = 'library' if os.path.abspath(p_path) != os.path.abspath(d_path) else 'program'
1468+
else:
1469+
d_type = 'library' if not pp.is_cwd and os.path.abspath(p_path) != os.path.abspath(d_path) else 'program'
1470+
1471+
if os.path.exists(d_path):
14641472
p = Program(d_path)
1465-
d_type = 'library' if p and not p.is_cwd and os.path.abspath(p_path) != os.path.abspath(d_path) else 'program'
1473+
if (d_type == 'program' and not p.is_cwd) or (d_type == 'library' and Repo.isrepo(d_path)):
1474+
error("A %s with name \"%s\" already exists." % (d_type, os.path.basename(d_path)), 1)
14661475

14671476
if scm and scm != 'none':
14681477
if os.path.isdir(d_path) and Repo.isrepo(d_path):
@@ -1486,7 +1495,6 @@ def new(name, scm='git', program=False, library=False, mbedlib=False, create_onl
14861495

14871496
action("Creating new %s \"%s\" (%s)" % (d_type, os.path.basename(d_path), scm))
14881497
p = Program(d_path)
1489-
14901498
if d_type == 'program':
14911499
# This helps sub-commands to display relative paths to the created program
14921500
cwd_root = os.path.abspath(d_path)
@@ -1544,7 +1552,7 @@ def import_(url, path=None, ignore=False, depth=None, protocol=None, top=True):
15441552
error("Directory \"%s\" is not empty. Please ensure that the destination folder is empty." % repo.path, 1)
15451553

15461554
text = "Importing program" if top else "Adding library"
1547-
action("%s \"%s\" from \"%s/\"%s" % (text, relpath(cwd_root, repo.path), repo.url, ' at '+(repo.revtype(repo.rev, True))))
1555+
action("%s \"%s\" from \"%s\"%s" % (text, relpath(cwd_root, repo.path), formaturl(repo.url, protocol), ' at '+(repo.revtype(repo.rev, True))))
15481556
if repo.clone(repo.url, repo.path, rev=repo.rev, depth=depth, protocol=protocol):
15491557
with cd(repo.path):
15501558
Program(repo.path).set_root()

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def read(fname):
1919
setup(
2020
name="mbed-cli",
2121
packages=["mbed"],
22-
version="0.8.3",
22+
version="0.8.5",
2323
url='http://github.com/ARMmbed/mbed-cli',
2424
author='ARM mbed',
2525
author_email='[email protected]',

0 commit comments

Comments
 (0)