Skip to content

Commit

Permalink
Updated build.py (and libs) to have extended --status functionality. …
Browse files Browse the repository at this point in the history
…Note; this needs to be pushed upstream to the codal/ library
  • Loading branch information
JohnVidler committed Jul 20, 2023
1 parent 2c887df commit c576ffd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
parser.add_option('-M', '--major', dest='update_major', action="store_true", help='With -l, update major version', default=False)
parser.add_option('-V', '--version', dest='version', metavar="VERSION", help='With -l, set the version; use "-V v0.0.1" to bootstrap', default=False)
parser.add_option('-v', '--verbose', dest='verbose', action="store_true", help='Increases verbosity)', default=False)
parser.add_option('-u', '--update', dest='update', action="store_true", help='git pull target and libraries', default=False)
parser.add_option('-u', '--update', dest='update', action="store_true", help='git pull target and libraries, use with "-d/--dev" to update all libraries to their latest master' , default=False)
parser.add_option('-s', '--status', dest='status', action="store_true", help='git status target and libraries', default=False)
parser.add_option('-r', '--revision', dest='revision', action="store", help='Checkout a specific revision of the target', default=False)
parser.add_option('-d', '--dev', dest='dev', action="store_true", help='enable developer mode (does not use target-locked.json)', default=False)
Expand All @@ -58,7 +58,7 @@
exit(0)

if options.update:
update()
update(sync_dev = options.dev)
exit(0)

if options.status:
Expand Down
8 changes: 6 additions & 2 deletions utils/python/codal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,16 @@ def read_config():
target = read_json("libraries/" + targetdir + "/target.json")
return (codal, targetdir, target)

def update(allow_detached=False):
def update(allow_detached=False, sync_dev=False):
(codal, targetdir, target) = read_config()
dirname = os.getcwd()
for ln in target['libraries']:
os.chdir(dirname + "/libraries/" + ln['name'])
system("git checkout " + ln['branch'])
if sync_dev:
default_branch = list(filter( lambda v: v.strip().startswith('HEAD'), str(subprocess.check_output( ["git", "remote", "show", "origin"] ), "utf8").splitlines()))[0].split(":")[1].strip()
system("git checkout " + default_branch)
else:
system("git checkout " + ln['branch'])
system("git pull")
os.chdir(dirname + "/libraries/" + targetdir)
if ("HEAD detached" in os.popen('git branch').read().strip() and
Expand Down

0 comments on commit c576ffd

Please sign in to comment.