def _get_commits(self, repos, rev): """Get commit info from svn revision using svnlook.""" # collect the info changed = _svnlook("changed", repos, rev) log = _svnlook("log", repos, rev) author = _svnlook("author", repos, rev) date = _svnlook("date", repos, rev) # prepare hook payload in the github payload format changes = {"A": [], "U": [], "D": []} paths = [] for line in changed: oper, path = line.split() # Used oper[0] to work with 'UU' operation if oper[0] in changes: changes[oper[0]].append(path) paths.append(os.path.join(repos, path)) url = get_repo_url(paths, self._config) return ( url, [ { "author": {"name": author, "email": ""}, "id": rev, "added": changes["A"], "modified": changes["U"], "removed": changes["D"], "message": log, "timestamp": date, } ], )
def postreceive(self, commits): """Postcommit hook.""" # Get command line arguments for commit in commits: old, new, ref = commit # Send the payload self._sender.send_payload({ "before": old, "after": new, "ref": ref, "repository": { "url": get_repo_url([os.getcwd()], self._config), "name": "", "description": "", "owner": { "email": "", "name": "" } }, "commits": self._get_commits(old, new, ref), })