Lines Matching +full:- +full:- +full:branch
3 # Use of this source code is governed by a BSD-style license that can be
28 You need to be on a local branch tracking a remote one. `repo start` does this
31 $ git checkout -b mybranch --track origin/main
37 If you are tracking a different branch (e.g. aosp/main or cros/chromeos), the upload may
39 create a new branch tracking origin/main and cherry-picks your commits.
42 [mybranch-upstream] ... resolve conflicts
43 [mybranch-upstream] $ git add .
44 [mybranch-upstream] $ git cherry-pick --continue
45 [mybranch-upstream] $ ./tools/cl upload
49 GERRIT_URL = "https://chromium-review.googlesource.com"
54 curl = cmd("curl --silent --fail")
61 branch: str
68 def list_changes(cls, branch: str):
69 upstream = get_upstream(branch)
70 for line in git(f'log "--format=%H %s" --first-parent {upstream}..{branch}').lines():
76 msg = git("log -1 --format=email", self.sha).stdout()
77 match = re.search("^Change-Id: (I[a-f0-9]+)", msg, re.MULTILINE)
99 def get_upstream(branch: str = ""):
101 return git(f"rev-parse --abbrev-ref --symbolic-full-name {branch}@{{u}}").stdout()
107 return git("for-each-ref --format=%(refname:short) refs/heads").lines()
114 if confirm(f"You are not tracking an upstream branch. Set upstream to {default_upstream}?"):
115 git(f"branch --set-upstream-to {default_upstream}").fg()
118 raise Exception("You are not tracking an upstream branch.")
121 raise Exception(f"Your upstream branch '{upstream}' is not remote.")
126 if not git("remote get-url origin").success():
129 if git("remote get-url origin").stdout() not in [CROSVM_URL, CROSVM_SSO]:
132 git("remote set-url origin", CROSVM_URL).fg()
137 hooks_dir = Path(git("rev-parse --git-path hooks").stdout())
138 hook_path = hooks_dir / "commit-msg"
141 curl(f"{GERRIT_URL}/tools/hooks/commit-msg").write_to(hook_path)
145 def print_branch_summary(branch: str):
146 upstream = get_upstream(branch)
148 print("Branch", branch, "is not tracking an upstream branch")
151 print("Branch", branch, "tracking", upstream)
152 changes = [*LocalChange.list_changes(branch)]
168 for branch in list_local_branches():
169 print_branch_summary(branch)
176 current_branch = git("branch --show-current").stdout()
178 branch
179 for branch in list_local_branches()
180 if branch != current_branch
181 and get_upstream(branch) is not None
183 change.status in ["ABANDONED", "MERGED"] for change in LocalChange.list_changes(branch)
192 for branch in branches_to_delete:
193 print_branch_summary(branch)
196 git("branch", "-D", *branches_to_delete).fg()
201 Rebases changes from the current branch onto origin/main.
203 Will create a new branch called 'current-branch'-upstream tracking origin/main. Changes from
204 the current branch will then be rebased into the -upstream branch.
206 branch_name = git("branch --show-current").stdout()
207 upstream_branch_name = branch_name + "-upstream"
209 if git("rev-parse", upstream_branch_name).success():
210 print(f"Overwriting existing branch {upstream_branch_name}")
211 git("log -n1", upstream_branch_name).fg()
213 git("fetch -q origin main").fg()
214 git("checkout -B", upstream_branch_name, "origin/main").fg()
216 print(f"Cherry-picking changes from {branch_name}")
217 git(f"cherry-pick {branch_name}@{{u}}..{branch_name}").fg()
228 Uploads changes to the crosvm main branch.
230 remote, branch = get_active_upstream()
245 if (remote, branch) != ("origin", "main"):
246 print(f"WARNING! Your changes are based on {remote}/{branch}, not origin/main.")
247 print("If gerrit rejects your changes, try `./tools/cl rebase -h`.")
255 extra_args.append("l=Auto-Submit+1")
258 extra_args.append("l=Commit-Queue+1")
260 extra_args.append(f"l=Commit-Queue+2")