-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlilypad.py
42 lines (35 loc) · 1.26 KB
/
lilypad.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import click
import subprocess
import os
@click.group()
def cli():
pass
@click.command()
def pull():
click.echo("Pulling latest changes for root...")
subprocess.run(['git', 'checkout', '--', './browser/src/assets/fs.json'])
result = subprocess.run(['git', 'pull'], capture_output=True, check=True)
print(result.stdout.decode('utf-8'))
if os.path.exists('src/private/.git'):
click.echo("Pulling latest changes for private...")
result = subprocess.run(['git', 'pull'], capture_output=True, check=True, cwd='./src/private')
print(result.stdout.decode('utf-8'))
def push_helper(text, cwd, message):
click.echo(f"Pushing local changes for {text}...")
subprocess.run(['git', 'add', '--all'], capture_output=True, cwd=cwd)
res = subprocess.run(['git', 'commit', '-m', message], capture_output=True, cwd=cwd)
if res.returncode != 0:
click.echo('No changes to commit.')
else:
subprocess.run(['git', 'push'], capture_output=True, check=True, cwd=cwd)
click.echo('Pushed changes for root.')
@click.argument('message', required=True)
@click.command()
def push(message):
push_helper('root', '.', message)
click.echo('')
push_helper('private', './src/private', message)
cli.add_command(pull)
cli.add_command(push)
if __name__ == '__main__':
cli()