Skip to content

Commit 0dfc945

Browse files
committed
remove "refs/remotes/" prefix, filter partial branches more optimally in test
Signed-off-by: Kipras Melnikovas <kipras@kipras.org>
1 parent ad3ee94 commit 0dfc945

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

git-stacked-rebase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ export function parseBranchWhichNeedsLocalCheckout(targets: NonNullable<Targets>
932932
}
933933

934934
function getFullNameOfBranchWithRemote(b: Pick<BranchWhoNeedsLocalCheckout, "fullNameOfBranchWithRemote"> | Pick<BranchWhoNeedsLocalCheckout, "wantedLocalBranchName" | "remoteName">): string {
935-
return "refs/remotes/" + (
935+
return (
936936
"fullNameOfBranchWithRemote" in b
937937
? b.fullNameOfBranchWithRemote
938938
: b.remoteName + "/" + b.wantedLocalBranchName

test/auto-checkout-remote-partial-branches.spec.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ import { nativeGetBranchNames } from "../native-git/branch";
1111
import { modifyLines } from "../humanOp";
1212

1313
import { setupRemoteRepo } from "./util/setupRemoteRepo";
14-
import { noop } from "../util/noop";
1514

1615
export default async function run() {
1716
await auto_checks_out_remote_partial_branches();
18-
//noop(auto_checks_out_remote_partial_branches)
19-
noop(give_chosen_name_to_local_branch)
20-
//await give_chosen_name_to_local_branch();
17+
await give_chosen_name_to_local_branch();
2118
}
2219

2320
async function auto_checks_out_remote_partial_branches() {
@@ -71,22 +68,27 @@ async function give_chosen_name_to_local_branch() {
7168
*/
7269
LocalBob.execSyncInRepo(`git checkout ${RemoteAlice.latestStackedBranchName}`);
7370

74-
const remotePartialBranchesInAlice: string[] = RemoteAlice.partialBranches.map((b) => b.shorthand());
75-
const localPartialBranchesInBobBefore: string[] = findPartialBranchesThatArePresentLocally();
71+
const renamedLocalBranch = "partial-renamed-local-branch-hehe" as const;
7672

77-
function findPartialBranchesThatArePresentLocally(
78-
localBranches: string[] = nativeGetBranchNames(LocalBob.repo.workdir())("local")
79-
) {
80-
return remotePartialBranchesInAlice.filter((partial) => localBranches.includes(partial));
73+
const isPartial = (b: string): boolean => b.includes("partial")
74+
75+
assert(isPartial(renamedLocalBranch))
76+
77+
// TODO TS
78+
// @ts-ignore
79+
const remotePartialBranchesInAlice: string[] = findPartialBranches(RemoteAlice);
80+
const localPartialBranchesInBobBefore: string[] = findPartialBranches(LocalBob)
81+
82+
// TODO CLEANUP PREV TEST TOO
83+
function findPartialBranches(owner: typeof RemoteAlice | typeof LocalBob, workdir = owner.repo.workdir()): string[] {
84+
return nativeGetBranchNames(workdir)("local").filter(isPartial)
8185
}
8286

8387
assert.deepStrictEqual(
8488
localPartialBranchesInBobBefore.length,
8589
0,
8690
"expected partial branches to __not be__ checked out locally, to be able to test later that they will be."
8791
);
88-
89-
const renamedLocalBranch = "renamed-local-branch-hehe" as const;
9092

9193
await gitStackedRebase(RemoteAlice.initialBranch, {
9294
gitDir: LocalBob.repo.workdir(),
@@ -112,7 +114,7 @@ async function give_chosen_name_to_local_branch() {
112114
},
113115
});
114116

115-
const localPartialBranchesInBobAfter: string[] = findPartialBranchesThatArePresentLocally();
117+
const localPartialBranchesInBobAfter: string[] = findPartialBranches(LocalBob)
116118

117119
console.log({
118120
remotePartialBranchesInAlice,

0 commit comments

Comments
 (0)