Added really shoddy, probably broken git plugin
This commit is contained in:
parent
d32619063a
commit
8b1de13c8e
4 changed files with 45 additions and 24 deletions
40
plugins/update.py
Normal file
40
plugins/update.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from git import Repo
|
||||
|
||||
|
||||
from util import hook, web
|
||||
|
||||
@hook.command
|
||||
def update(inp, bot=None):
|
||||
repo = Repo()
|
||||
git = repo.git
|
||||
pull = git.pull()
|
||||
if "\n" in pull:
|
||||
return web.haste(pull)
|
||||
else:
|
||||
return pull
|
||||
|
||||
|
||||
@hook.command
|
||||
def version(inp, bot=None):
|
||||
repo = Repo()
|
||||
|
||||
# get origin and fetch it
|
||||
origin = repo.remotes.origin
|
||||
info = origin.fetch()
|
||||
|
||||
# get objects
|
||||
head = repo.head
|
||||
origin_head = info[0]
|
||||
current_commit = head.commit
|
||||
remote_commit = origin_head.commit
|
||||
|
||||
if current_commit == remote_commit:
|
||||
in_sync = True
|
||||
else:
|
||||
in_sync = False
|
||||
|
||||
# output
|
||||
return "Local {} is at commit {}, remote {} is at commit {}." \
|
||||
" You {} running the latest version.".format(head, current_commit.name_rev[:7],
|
||||
origin_head, remote_commit.name_rev[:7],
|
||||
"are" if in_sync else "are not")
|
Reference in a new issue