Skip to content

Commit 03755a9

Browse files
author
Zinc Lim
committed
review_patch: Parser and logging of series data
-This is currently ran on CLI but in future, the entry point might be slightly modified to fit into the linux CI system -The end goal of this project is to integrate an AI code reviewer into our CI process Signed-off-by: Zinc Lim <[email protected]>
1 parent c6748a0 commit 03755a9

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

review_patch.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python3
2+
# SPDX-License-Identifier: GPL-2.0
3+
#
4+
# Copyright (c) 2020 Facebook
5+
6+
import argparse
7+
import configparser
8+
9+
import requests
10+
from core import log, log_end_sec, log_init, log_open_sec
11+
from pw import Patchwork
12+
13+
14+
def main():
15+
parser = argparse.ArgumentParser(
16+
description="AI Code Reviewer for Patchwork",
17+
usage="%(prog)s --series SERIES_ID [--output OUTPUT]\n\n"
18+
"Examples:\n"
19+
" %(prog)s --series 1016234\n"
20+
" %(prog)s --series 1016234 --output series.html",
21+
)
22+
parser.add_argument(
23+
"--series", "-s", required=True, type=int, help="Series ID to fetch"
24+
)
25+
parser.add_argument("--output", "-o", help="Output file (default: print to stdout)")
26+
27+
args = parser.parse_args()
28+
29+
config = configparser.ConfigParser()
30+
config.read(["nipa.config", "pw.config", "review.config"])
31+
32+
log_init(
33+
config.get("log", "type", fallback="stdout"),
34+
config.get("log", "file", fallback=None),
35+
)
36+
37+
pw = Patchwork(config)
38+
39+
series = pw.get("series", args.series)
40+
log_open_sec(f"Logging series {args.series} data")
41+
log("Series information", series)
42+
log_end_sec()
43+
44+
45+
if __name__ == "__main__":
46+
main()

0 commit comments

Comments
 (0)