Add default Rust project reviewers and Test tag
* Add default reviewers for a few external/rust/crates projects;
more could be added later.
When a rust project is not found in the map,
a random reviewers is picked from a list.
* Add a Test tag to git commit message.
Bug: 162988933
Test: out/.../bin/external_updater update --branch_and_commit --push_change <some_project>
Change-Id: I3f04dce0b801e4f33980a57347a2affd1438ead0
diff --git a/git_utils.py b/git_utils.py
index 69dcfba..5402af9 100644
--- a/git_utils.py
+++ b/git_utils.py
@@ -19,6 +19,7 @@
from pathlib import Path
from typing import Dict, List, Tuple
+import reviewers
def _run(cmd: List[str], cwd: Path) -> str:
"""Runs a command and returns its output."""
@@ -161,4 +162,8 @@
def push(proj_path: Path, remote_name: str) -> None:
"""Pushes change to remote."""
- _run(['git', 'push', remote_name, 'HEAD:refs/for/master'], cwd=proj_path)
+ reviewer = reviewers.find_reviewer(str(proj_path))
+ if reviewer: # no '%r=' parameter if there is no reviewer found
+ reviewer = '%r=' + reviewer
+ _run(['git', 'push', remote_name, 'HEAD:refs/for/master' + reviewer],
+ cwd=proj_path)