Skip to content

Commit

Permalink
added: refresh repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Cui committed Feb 15, 2019
1 parent eba9ef1 commit d7e04bf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

12 changes: 12 additions & 0 deletions errbot-plugin/cron.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#/usr/bin/env python3
from gitutil.configure import Configuration
from gitutil.commands import GitCommand
import os

REPOSITORY_CONFIG_FILE = os.getenv("REPOSITORY_CONFIG_FILE")
REPOSITORY_NAME = os.getenv("REPOSITORY")
config = Configuration(REPOSITORY_CONFIG_FILE)

for branch in config["branches"]:
cmd = GitCommand(branch["path"])
cmd.pull()
10 changes: 10 additions & 0 deletions errbot-plugin/transbot/transbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import githubutil
from githubutil.github import GithubOperator
from gitutil.configure import Configuration as RepoConfig
from gitutil.commands import GitCommand
from transutil.transutil import TranslateUtil
from errbot import BotPlugin, botcmd, arg_botcmd

Expand Down Expand Up @@ -332,6 +333,15 @@ def show_limit(self, msg, args):
limit["search"]["reset"],
)

@botcmd
def refresh_repositories(self, msg, args):
config = RepoConfig(REPOSITORY_CONFIG_FILE)
branches = config.get_repository(REPOSITORY_NAME)["branches"]
for branch in branches:
cmd = GitCommand(branch["path"])
cmd.pull()
yield ("{} had been updated.".format((branch["path"])))

# @arg_botcmd('repository', type=str)
# @arg_botcmd('--count', type=int, default=10)
# def list_release(self, msg, repository, count):
Expand Down
4 changes: 4 additions & 0 deletions gitutil/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,7 @@ def get_diff_by_hash(self, filename, new_hashcode, old_hashcode):
filename
]
return self.__command_wrapper(command).strip()

def pull(self):
command = ["pull"]
return self.__command_wrapper(command).strip()

0 comments on commit d7e04bf

Please sign in to comment.