Skip to content

Commit a881c0e

Browse files
committed
feat(submit): make forges branch-agnostic
It was previously assumed that all forges would want to create and operate on branches, and, in fact, the calling `git-branchless-submit` code would even create the branches returned by `CreateStatus`. This has turned out not to be the case. For example, the Phabricator forge embeds the commit identifier in the (updated) commit message, and doesn't need a branch (and, in practice, it's turned out to be more annoying than useful to create the branches as shorthand identifiers). This commit removes the auto-branch-creation behavior and updates the terminology to be branch-agnostic and refer to "commits" instead of "branches". As a result, commits are now "submitted" at the beginning of their submission lifecycle, and future pushes (etc.) are "updates". This doesn't exactly make sense with the name of the `--create` flag, since we never refer to "creating" a commit anywhere, only "submitting" one, so we might want to change that flag name or terminology in the future.
1 parent 167aaa1 commit a881c0e

File tree

5 files changed

+145
-130
lines changed

5 files changed

+145
-130
lines changed

git-branchless-submit/src/branch_forge.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ impl Forge for BranchForge<'_> {
144144
[] => CommitStatus {
145145
submit_status: SubmitStatus::Local,
146146
remote_name: None,
147-
local_branch_name: None,
148-
remote_branch_name: None,
147+
local_commit_name: None,
148+
remote_commit_name: None,
149149
},
150150

151151
[BranchInfo {
@@ -156,8 +156,8 @@ impl Forge for BranchForge<'_> {
156156
None => CommitStatus {
157157
submit_status: SubmitStatus::Unsubmitted,
158158
remote_name: None,
159-
local_branch_name: Some(branch_name.clone()),
160-
remote_branch_name: None,
159+
local_commit_name: Some(branch_name.clone()),
160+
remote_commit_name: None,
161161
},
162162

163163
Some(upstream_branch) => CommitStatus {
@@ -167,16 +167,16 @@ impl Forge for BranchForge<'_> {
167167
SubmitStatus::NeedsUpdate
168168
},
169169
remote_name: remote_name.clone(),
170-
local_branch_name: Some(branch_name.clone()),
171-
remote_branch_name: Some(upstream_branch.get_name()?.to_owned()),
170+
local_commit_name: Some(branch_name.clone()),
171+
remote_commit_name: Some(upstream_branch.get_name()?.to_owned()),
172172
},
173173
},
174174

175175
_branch_infos => CommitStatus {
176176
submit_status: SubmitStatus::Unknown,
177177
remote_name: None,
178-
local_branch_name: None,
179-
remote_branch_name: None,
178+
local_commit_name: None,
179+
remote_commit_name: None,
180180
},
181181
};
182182
commit_statuses.insert(*commit_oid, commit_status);
@@ -196,10 +196,10 @@ impl Forge for BranchForge<'_> {
196196
let CommitStatus {
197197
submit_status: _,
198198
remote_name: _,
199-
local_branch_name,
200-
remote_branch_name: _,
199+
local_commit_name,
200+
remote_commit_name: _,
201201
} = commit_status;
202-
local_branch_name.clone()
202+
local_commit_name.clone()
203203
})
204204
.sorted()
205205
.collect_vec();
@@ -244,12 +244,12 @@ These remotes are available: {}",
244244
Ok(Ok(commits
245245
.into_iter()
246246
.filter_map(|(commit_oid, commit_status)| {
247-
commit_status.local_branch_name.map(|local_branch_name| {
247+
commit_status.local_commit_name.map(|local_commit_name| {
248248
(
249249
commit_oid,
250250
CreateStatus {
251251
final_commit_oid: commit_oid,
252-
local_branch_name,
252+
local_commit_name,
253253
},
254254
)
255255
})
@@ -269,9 +269,9 @@ These remotes are available: {}",
269269
CommitStatus {
270270
submit_status: _,
271271
remote_name: Some(remote_name),
272-
local_branch_name: Some(local_branch_name),
273-
remote_branch_name: _,
274-
} => Some((remote_name, local_branch_name)),
272+
local_commit_name: Some(local_commit_name),
273+
remote_commit_name: _,
274+
} => Some((remote_name, local_commit_name)),
275275
commit_status => {
276276
warn!(
277277
?commit_status,

0 commit comments

Comments
 (0)