Skip to content

Commit cc37099

Browse files
committed
Add '--message' param to mbed publish to allow automation (#228)
1 parent 43aa103 commit cc37099

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

mbed/mbed.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ def remove(dest):
384384
except ProcessException:
385385
pass
386386

387-
def commit():
388-
popen([hg_cmd, 'commit'] + (['-v'] if very_verbose else ([] if verbose else ['-q'])))
387+
def commit(msg=None):
388+
popen([hg_cmd, 'commit'] + (['-m', msg] if msg else []) + (['-v'] if very_verbose else ([] if verbose else ['-q'])))
389389

390390
def publish(all_refs=None):
391391
popen([hg_cmd, 'push'] + (['--new-branch'] if all_refs else []) + (['-v'] if very_verbose else ([] if verbose else ['-q'])))
@@ -553,8 +553,8 @@ def remove(dest):
553553
except ProcessException:
554554
pass
555555

556-
def commit():
557-
popen([git_cmd, 'commit', '-a'] + (['-v'] if very_verbose else ([] if verbose else ['-q'])))
556+
def commit(msg=None):
557+
popen([git_cmd, 'commit', '-a'] + (['-m', msg] if msg else []) + (['-v'] if very_verbose else ([] if verbose else ['-q'])))
558558

559559
def publish(all_refs=None):
560560
if all_refs:
@@ -1631,14 +1631,15 @@ def deploy(ignore=False, depth=None, protocol=None, top=True):
16311631
# Publish command
16321632
@subcommand('publish',
16331633
dict(name=['-A', '--all'], dest='all_refs', action='store_true', help='Publish all branches, including new ones. Default: push only the current branch.'),
1634+
dict(name=['-M', '--message'], dest='msg', type=str, nargs='?', help='Commit message. Default: prompts for commit message.'),
16341635
help='Publish program or library',
16351636
description=(
16361637
"Publishes this %s and all dependencies to their associated remote\nrepository URLs.\n"
16371638
"This command performs various consistency checks for local uncommitted changes\n"
16381639
"and unpublished revisions and encourages to commit/push them.\n"
16391640
"Online guide about collaboration is available at:\n"
16401641
"www.mbed.com/collab_guide" % cwd_type))
1641-
def publish(all_refs=None, top=True):
1642+
def publish(all_refs=None, msg=None, top=True):
16421643
if top:
16431644
action("Checking for local modifications...")
16441645

@@ -1652,14 +1653,17 @@ def publish(all_refs=None, top=True):
16521653
if lib.check_repo():
16531654
with cd(lib.path):
16541655
progress()
1655-
publish(False, all_refs)
1656+
publish(all_refs, msg=msg, top=False)
16561657

16571658
sync(recursive=False)
16581659

16591660
if repo.dirty():
16601661
action("Uncommitted changes in %s \"%s\" in \"%s\"" % (repo.pathtype(repo.path), repo.name, repo.path))
1661-
raw_input('Press enter to commit and publish: ')
1662-
repo.commit()
1662+
if msg:
1663+
repo.commit(msg)
1664+
else:
1665+
raw_input('Press enter to commit and publish: ')
1666+
repo.commit()
16631667

16641668
try:
16651669
outgoing = repo.outgoing()

0 commit comments

Comments
 (0)