mirror of https://github.com/zulip/zulip.git
mypy: Annotate *api/integrations/svn/post-commit*.
This commit is contained in:
parent
5316c364bb
commit
3d015eb259
|
@ -34,6 +34,9 @@ import sys
|
|||
import os.path
|
||||
import pysvn
|
||||
|
||||
if False:
|
||||
from typing import Any, Dict, List, Optional, Text, Tuple, Union
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
import zulip_svn_config as config
|
||||
VERSION = "0.9"
|
||||
|
@ -46,26 +49,27 @@ client = zulip.Client(
|
|||
email=config.ZULIP_USER,
|
||||
site=config.ZULIP_SITE,
|
||||
api_key=config.ZULIP_API_KEY,
|
||||
client="ZulipSVN/" + VERSION)
|
||||
svn = pysvn.Client()
|
||||
client="ZulipSVN/" + VERSION) # type: zulip.Client
|
||||
svn = pysvn.Client() # type: pysvn.Client
|
||||
|
||||
path, rev = sys.argv[1:]
|
||||
path, rev = sys.argv[1:] # type: Tuple[Text, Text]
|
||||
|
||||
# since its a local path, prepend "file://"
|
||||
path = "file://" + path
|
||||
|
||||
entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[0]
|
||||
message = """**{0}** committed revision r{1} to `{2}`.
|
||||
entry = svn.log(path, revision_end=pysvn.Revision(pysvn.opt_revision_kind.number, rev))[0] # type: Dict[Text, Union[Text, pysvn.Revision, List[Dict[Text, pysvn.Revision]]]]
|
||||
message = "**{0}** committed revision r{1} to `{2}`.\n\n> {3}".format(
|
||||
entry['author'],
|
||||
rev,
|
||||
path.split('/')[-1],
|
||||
entry['revprops']['svn:log']) # type: Text
|
||||
|
||||
> {3}
|
||||
""".format(entry['author'], rev, path.split('/')[-1], entry['revprops']['svn:log'])
|
||||
|
||||
destination = config.commit_notice_destination(path, rev)
|
||||
destination = config.commit_notice_destination(path, rev) # type: Optional[Dict[Text, Text]]
|
||||
|
||||
message_data = {
|
||||
"type": "stream",
|
||||
"to": destination["stream"],
|
||||
"subject": destination["subject"],
|
||||
"content": message,
|
||||
}
|
||||
} # type: Dict[str, Any]
|
||||
client.send_message(message_data)
|
||||
|
|
|
@ -33,7 +33,6 @@ api/integrations/codebase/zulip_codebase_mirror
|
|||
api/integrations/git/post-receive
|
||||
api/integrations/nagios/nagios-notify-zulip
|
||||
api/integrations/rss/rss-bot
|
||||
api/integrations/svn/post-commit
|
||||
api/integrations/twitter/twitter-bot
|
||||
api/integrations/twitter/twitter-search-bot
|
||||
tools/deprecated/iframe-bot/show-last-messages
|
||||
|
|
Loading…
Reference in New Issue