mypy: Annotate *bots/githook-post-receive*

This commit is contained in:
Joy Chen 2016-12-03 15:58:22 -06:00
parent 77d11cd300
commit b4fc87745a

View file

@ -30,6 +30,7 @@
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
from __future__ import absolute_import from __future__ import absolute_import
from typing import Text
import os import os
import sys import sys
import subprocess import subprocess
@ -50,6 +51,7 @@ client = zulip.Client(
client="ZulipGit/" + VERSION) client="ZulipGit/" + VERSION)
def git_repository_name(): def git_repository_name():
# type: () -> Text
output = subprocess.check_output(["git", "rev-parse", "--is-bare-repository"]) output = subprocess.check_output(["git", "rev-parse", "--is-bare-repository"])
if output.strip() == "true": if output.strip() == "true":
return os.path.basename(os.getcwd())[:-len(".git")] return os.path.basename(os.getcwd())[:-len(".git")]
@ -57,6 +59,7 @@ def git_repository_name():
return os.path.basename(os.path.dirname(os.getcwd())) return os.path.basename(os.path.dirname(os.getcwd()))
def git_commit_range(oldrev, newrev): def git_commit_range(oldrev, newrev):
# type: (str, str) -> str
log_cmd = ["git", "log", "--reverse", log_cmd = ["git", "log", "--reverse",
"--pretty=%aE %H %s", "%s..%s" % (oldrev, newrev)] "--pretty=%aE %H %s", "%s..%s" % (oldrev, newrev)]
commits = '' commits = ''
@ -69,6 +72,7 @@ def git_commit_range(oldrev, newrev):
return commits return commits
def send_bot_message(oldrev, newrev, refname): def send_bot_message(oldrev, newrev, refname):
# type: (str, str, str) -> None
repo_name = git_repository_name() repo_name = git_repository_name()
branch = refname.replace('refs/heads/', '') branch = refname.replace('refs/heads/', '')
destination = config.commit_notice_destination(repo_name, branch, newrev) destination = config.commit_notice_destination(repo_name, branch, newrev)