Skip to content

Commit b69cbe1

Browse files
authored
[BE] [Bot] Add --into as an alias for --onto in cherry-pick command (#6498)
I've been seeing people often try to use --into instead of --onto when using the PyTorch bot's cherry-pick command, as both parameters are semantically reasonable. This change adds --into as an alias for the --onto parameter, allowing users to use either version without getting an error. The implementation leverages the argparse library's ability to have multiple option strings for the same argument. Added tests to verify that both parameter versions work correctly.
1 parent fe34c91 commit b69cbe1

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

torchci/lib/bot/cliParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const cherryPick = commands.add_parser("cherry-pick", {
155155
formatter_class: RawTextHelpFormatter,
156156
add_help: false,
157157
});
158-
cherryPick.add_argument("--onto", {
158+
cherryPick.add_argument("--onto", "--into", {
159159
required: true,
160160
help: "Branch you would like to cherry pick onto (Example: release/2.1)",
161161
});

torchci/test/cliParser.test.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { getParser } from "../lib/bot/cliParser";
2+
3+
describe("CLI Parser", () => {
4+
describe("cherry-pick command", () => {
5+
it("should accept --onto parameter", () => {
6+
const parser = getParser();
7+
const args = parser.parse_args([
8+
"cherry-pick",
9+
"--onto",
10+
"release/2.1",
11+
"-c",
12+
"regression",
13+
]);
14+
15+
expect(args.command).toBe("cherry-pick");
16+
expect(args.onto).toBe("release/2.1");
17+
expect(args.classification).toBe("regression");
18+
});
19+
20+
it("should accept --into as an alias for --onto", () => {
21+
const parser = getParser();
22+
const args = parser.parse_args([
23+
"cherry-pick",
24+
"--into",
25+
"release/2.1",
26+
"-c",
27+
"regression",
28+
]);
29+
30+
expect(args.command).toBe("cherry-pick");
31+
expect(args.onto).toBe("release/2.1"); // Value should be stored in args.onto regardless of flag used
32+
expect(args.classification).toBe("regression");
33+
});
34+
});
35+
});

0 commit comments

Comments
 (0)