зеркало из https://github.com/mozilla/bugbug.git
Apply the Phabricator patch right after cloning in the commit classifier script (#3392)
Fixes #1268
This commit is contained in:
Родитель
d436379f01
Коммит
e499bd5978
|
@ -136,6 +136,8 @@ class CommitClassifier(object):
|
|||
method_defect_predictor_dir: str,
|
||||
use_single_process: bool,
|
||||
skip_feature_importance: bool,
|
||||
phabricator_deployment: Optional[str] = None,
|
||||
diff_id: Optional[int] = None,
|
||||
):
|
||||
self.model_name = model_name
|
||||
self.repo_dir = repo_dir
|
||||
|
@ -149,6 +151,14 @@ class CommitClassifier(object):
|
|||
"hg::https://hg.mozilla.org/mozilla-central", git_repo_dir
|
||||
)
|
||||
|
||||
self.revision = None
|
||||
if diff_id is not None:
|
||||
assert phabricator_deployment is not None
|
||||
with hglib.open(self.repo_dir) as hg:
|
||||
self.apply_phab(hg, phabricator_deployment, diff_id)
|
||||
|
||||
self.revision = hg.log(revrange="not public()")[0].node.decode("utf-8")
|
||||
|
||||
self.method_defect_predictor_dir = method_defect_predictor_dir
|
||||
if method_defect_predictor_dir:
|
||||
self.clone_git_repo(
|
||||
|
@ -583,25 +593,13 @@ class CommitClassifier(object):
|
|||
def classify(
|
||||
self,
|
||||
revision: Optional[str] = None,
|
||||
phabricator_deployment: Optional[str] = None,
|
||||
diff_id: Optional[int] = None,
|
||||
runnable_jobs_path: Optional[str] = None,
|
||||
) -> None:
|
||||
if revision is not None:
|
||||
assert phabricator_deployment is None
|
||||
assert diff_id is None
|
||||
|
||||
if diff_id is not None:
|
||||
assert phabricator_deployment is not None
|
||||
assert revision is None
|
||||
|
||||
self.update_commit_db()
|
||||
|
||||
if phabricator_deployment is not None and diff_id is not None:
|
||||
with hglib.open(self.repo_dir) as hg:
|
||||
self.apply_phab(hg, phabricator_deployment, diff_id)
|
||||
|
||||
revision = hg.log(revrange="not public()")[0].node.decode("utf-8")
|
||||
if self.revision is not None:
|
||||
assert revision is None
|
||||
revision = self.revision
|
||||
|
||||
commits = repository.download_commits(
|
||||
self.repo_dir,
|
||||
|
@ -855,6 +853,14 @@ def main() -> None:
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.revision is not None:
|
||||
assert args.phabricator_deployment is None
|
||||
assert args.diff_id is None
|
||||
|
||||
if args.diff_id is not None:
|
||||
assert args.phabricator_deployment is not None
|
||||
assert args.revision is None
|
||||
|
||||
classifier = CommitClassifier(
|
||||
args.model,
|
||||
args.repo_dir,
|
||||
|
@ -862,10 +868,10 @@ def main() -> None:
|
|||
args.method_defect_predictor_dir,
|
||||
args.use_single_process,
|
||||
args.skip_feature_importance,
|
||||
args.phabricator_deployment,
|
||||
args.diff_id,
|
||||
)
|
||||
classifier.classify(
|
||||
args.revision, args.phabricator_deployment, args.diff_id, args.runnable_jobs
|
||||
)
|
||||
classifier.classify(args.revision, args.runnable_jobs)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Загрузка…
Ссылка в новой задаче