зеркало из https://github.com/mozilla/bugbug.git
Add a method to retrieve a Phabricator revision ID from a commit
This commit is contained in:
Родитель
6e4360dd2a
Коммит
9ede8db0e0
|
@ -12,6 +12,7 @@ import logging
|
|||
import math
|
||||
import os
|
||||
import pickle
|
||||
import re
|
||||
import shelve
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -108,6 +109,10 @@ TYPES_TO_EXT = {**SOURCE_CODE_TYPES_TO_EXT, **OTHER_TYPES_TO_EXT}
|
|||
|
||||
EXT_TO_TYPES = {ext: typ for typ, exts in TYPES_TO_EXT.items() for ext in exts}
|
||||
|
||||
PHABRICATOR_REVISION_REGEX = re.compile(
|
||||
"Differential Revision: (https://phabricator.services.mozilla.com/D([0-9]+))"
|
||||
)
|
||||
|
||||
|
||||
def get_type(path: str) -> str:
|
||||
file_name = os.path.basename(path)
|
||||
|
@ -290,6 +295,13 @@ def get_commits(
|
|||
)
|
||||
|
||||
|
||||
def get_revision_id(commit):
|
||||
match = PHABRICATOR_REVISION_REGEX.search(commit["desc"])
|
||||
if not match:
|
||||
return None
|
||||
return int(match.group(2))
|
||||
|
||||
|
||||
def _init_process(repo_dir):
|
||||
global HG, REPO_DIR
|
||||
REPO_DIR = repo_dir
|
||||
|
|
|
@ -1859,3 +1859,15 @@ def test_get_commits():
|
|||
}
|
||||
assert len(retrieved_commits) == 10
|
||||
assert included_commits.issubset({c["node"] for c in retrieved_commits})
|
||||
|
||||
|
||||
def test_get_revision_id():
|
||||
commit = {
|
||||
"desc": "My desc",
|
||||
}
|
||||
assert repository.get_revision_id(commit) is None
|
||||
|
||||
commit = {
|
||||
"desc": "Bug 1667333: Remove unnecessary prefs for mime type checking r=necko-reviewers,evilpie,valentin\n\nDifferential Revision: https://phabricator.services.mozilla.com/D91406",
|
||||
}
|
||||
assert repository.get_revision_id(commit) == 91406
|
||||
|
|
Загрузка…
Ссылка в новой задаче