Show commit on GitHub after pushing from local
This commit is contained in:
parent
c0b47da0e8
commit
362295877c
17
dotman.py
17
dotman.py
@ -12,7 +12,7 @@ from termcolor import colored, cprint
|
|||||||
DOTFILES_REPOSITORY = '$HOME/repos/dotfiles'
|
DOTFILES_REPOSITORY = '$HOME/repos/dotfiles'
|
||||||
REMOTE_REPOSITORY = 'https://github.com/fybx/dotfiles'
|
REMOTE_REPOSITORY = 'https://github.com/fybx/dotfiles'
|
||||||
LOCAL_CONFIG = '$HOME/.config'
|
LOCAL_CONFIG = '$HOME/.config'
|
||||||
VER = 'v1.5'
|
VER = 'v1.6'
|
||||||
help_message = f'''
|
help_message = f'''
|
||||||
dotman {VER} dotfiles manager by fyb
|
dotman {VER} dotfiles manager by fyb
|
||||||
|
|
||||||
@ -89,13 +89,19 @@ def commit_then_push():
|
|||||||
# I forget checking out to main after testing on a seperate branch
|
# I forget checking out to main after testing on a seperate branch
|
||||||
# Line below checks out for me every time it's run
|
# Line below checks out for me every time it's run
|
||||||
proc('/usr/bin/git checkout main', DOTFILES_REPOSITORY)
|
proc('/usr/bin/git checkout main', DOTFILES_REPOSITORY)
|
||||||
|
proc('/usr/bin/git fetch', DOTFILES_REPOSITORY)
|
||||||
|
proc('/usr/bin/git pull', DOTFILES_REPOSITORY)
|
||||||
proc('/usr/bin/git add .', DOTFILES_REPOSITORY)
|
proc('/usr/bin/git add .', DOTFILES_REPOSITORY)
|
||||||
date = dt.now().strftime('%d.%m.%Y %H.%M')
|
date = dt.now().strftime('%d.%m.%Y %H.%M')
|
||||||
_, output = proc(f'/usr/bin/git commit -m "dotman {date}"', DOTFILES_REPOSITORY)
|
_, output = proc(f'/usr/bin/git commit -m "dotman {date}"', DOTFILES_REPOSITORY)
|
||||||
if 'nothing to commit' not in output:
|
if 'nothing to commit' not in output:
|
||||||
code, output = proc('/usr/bin/git push', DOTFILES_REPOSITORY)
|
code, output = proc('/usr/bin/git push', DOTFILES_REPOSITORY)
|
||||||
return 0 if code == 0 else 2
|
if code == 0:
|
||||||
return 1
|
_, output = proc('/usr/bin/git log', DOTFILES_REPOSITORY)
|
||||||
|
commit = output.split('\n')[0].replace('commit ', '')
|
||||||
|
return 3, commit
|
||||||
|
return 0, None if code == 0 else 2, None
|
||||||
|
return 1, None
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -153,13 +159,16 @@ def main():
|
|||||||
special_copy(LOCAL_CONFIG, DOTFILES_REPOSITORY)
|
special_copy(LOCAL_CONFIG, DOTFILES_REPOSITORY)
|
||||||
print(colored('Step 2: ', 'magenta'), f'Create a commit and push to remote repo',
|
print(colored('Step 2: ', 'magenta'), f'Create a commit and push to remote repo',
|
||||||
colored(f'"{REMOTE_REPOSITORY}"', 'yellow'))
|
colored(f'"{REMOTE_REPOSITORY}"', 'yellow'))
|
||||||
stat = commit_then_push()
|
stat, _ = commit_then_push()
|
||||||
if stat == 0:
|
if stat == 0:
|
||||||
cprint('Backup completed. Have a nice day!', 'green')
|
cprint('Backup completed. Have a nice day!', 'green')
|
||||||
elif stat == 1:
|
elif stat == 1:
|
||||||
cprint('There was nothing to commit, aborting.', 'red')
|
cprint('There was nothing to commit, aborting.', 'red')
|
||||||
elif stat == 2:
|
elif stat == 2:
|
||||||
cprint('Couldn\'t push local to remote, aborting.', 'red')
|
cprint('Couldn\'t push local to remote, aborting.', 'red')
|
||||||
|
elif stat == 3:
|
||||||
|
url = f'{REMOTE_REPOSITORY}/commit/{_}'
|
||||||
|
cprint(f'Backup completed: {url}. Have a nice day!', 'green')
|
||||||
exit(stat)
|
exit(stat)
|
||||||
elif ans.lower() == 'd' or ans.lower() == 'deploy':
|
elif ans.lower() == 'd' or ans.lower() == 'deploy':
|
||||||
print(colored('Step 1:', 'magenta'), ' Copy from local repo to local config')
|
print(colored('Step 1:', 'magenta'), ' Copy from local repo to local config')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user