update arguments to be more consistent, allow specifying branch to update from

This commit is contained in:
yequari 2024-04-30 20:49:03 -07:00
parent 969e800973
commit f43c773628
1 changed files with 12 additions and 8 deletions

View File

@ -18,13 +18,17 @@ def site_update(args):
if p.returncode != 0:
return 1
if 'behind' in str(p.stdout):
p = subprocess.run(['git', 'merge', 'origin/master'], cwd=args.src)
if args.b:
p = subprocess.run(['git', 'merge', f'origin/{args.b}'], cwd=args.src)
if p.returncode != 0:
return 1
if args.b:
if args.dest is None:
print('need --dest argument for -b', file=sys.stderr)
p = subprocess.run(['git', 'merge', 'origin/master'], cwd=args.src)
if p.returncode != 0:
p = subprocess.run(['git', 'merge', 'origin/main'], cwd=args.src)
if p.returncode != 0:
return 1
if args.build:
args.dest = args.build
site_build(args)
else:
print('up to date')
@ -78,10 +82,10 @@ if __name__ == '__main__':
parser_build.set_defaults(func=site_build)
parser_update.add_argument('--src', required=True)
parser_update.add_argument('--dest', required=False)
parser_update.add_argument('-b', action='store_true', required=False)
parser_build.add_argument('--src', required=True)
parser_build.add_argument('--dest', required=True)
parser_update.add_argument('--build', required=False, help='build after updating from remote repository, takes destination directory as an argument')
parser_update.add_argument('-b', required=False, help='remote git branch to pull from')
parser_build.add_argument('--src', required=False, default='.')
parser_build.add_argument('dest')
args = parser.parse_args()
rc = args.func(args)