-
Notifications
You must be signed in to change notification settings - Fork 84
Expand file tree
/
Copy pathdefault_branch_change.py.test
More file actions
119 lines (94 loc) · 2.49 KB
/
Copy pathdefault_branch_change.py.test
File metadata and controls
119 lines (94 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
from ghstack.test_prelude import *
init_test()
commit("A")
(diff1,) = gh_submit("Initial 1")
assert diff1 is not None
# make main branch
git("branch", "main", "master")
git("push", "origin", "main")
# change default branch to main
get_github().patch(
"repos/pytorch/pytorch",
name="pytorch",
default_branch="main",
)
assert_github_state(
"""\
[O] #500 Commit A (gh/ezyang/1/head -> gh/ezyang/1/base)
Stack:
* __->__ #500
This is commit A
* 36fcfdf Initial 1
Repository state:
* 36fcfdf (gh/ezyang/1/head)
| Initial 1
* 5a32949 (gh/ezyang/1/base)
| Initial 1 (base update)
* dc8bfe4 (HEAD -> master)
Initial commit
"""
)
# land
gh_land(diff1.pr_url)
assert_expected_inline(
get_upstream_sh().git("log", "--oneline", "master"),
"""dc8bfe4 Initial commit""",
)
assert_expected_inline(
get_upstream_sh().git("log", "--oneline", "main"),
"""\
47df7ee Commit A (#500)
dc8bfe4 Initial commit""",
)
# make another commit
commit("B")
(diff2,) = gh_submit("Initial 2")
assert diff2 is not None
# change default branch back to master
get_github().patch(
"repos/pytorch/pytorch",
name="pytorch",
default_branch="master",
)
assert_github_state(
"""\
[O] #500 Commit A (gh/ezyang/1/head -> gh/ezyang/1/base)
Stack:
* __->__ #500
This is commit A
* 36fcfdf Initial 1
[O] #501 Commit B (gh/ezyang/2/head -> gh/ezyang/2/base)
Stack:
* __->__ #501
This is commit B
* d8c62d3 Initial 2
Repository state:
* d8c62d3 (gh/ezyang/2/head)
| Initial 2
* 66b4cd5 (gh/ezyang/2/base)
| Initial 2 (base update)
* 47df7ee (main, gh/ezyang/1/orig)
| Commit A (#500)
| * 36fcfdf (gh/ezyang/1/head)
| | Initial 1
| * 5a32949 (gh/ezyang/1/base)
|/ Initial 1 (base update)
* dc8bfe4 (HEAD -> master)
Initial commit
"""
)
# land again
gh_land(diff2.pr_url)
assert_expected_inline(
get_upstream_sh().git("log", "--oneline", "master"),
"""\
c9d09d0 Commit B (#501)
fd22a9f Commit A (#500)
dc8bfe4 Initial commit""",
)
assert_expected_inline(
get_upstream_sh().git("log", "--oneline", "main"),
"""\
47df7ee Commit A (#500)
dc8bfe4 Initial commit""",
)