Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
kiprasmel committed Aug 27, 2023
1 parent b46d2aa commit ec91c5c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 29 deletions.
44 changes: 17 additions & 27 deletions ref-finder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,35 +319,30 @@ export const isNewRangeDiffLine = (line: string, nth_before: string) => {
export type EasyScenarioRet = {
is_easy_repair_scenario: boolean;
//
eq_from: number;
eq_till: number;
eq_count: number;
//
ahead_from: number;
ahead_till: number;
ahead_count: number;
eq_indices: Set<number>;
ahead_indices: Set<number>;
//
behind_from: number;
behind_till: number;
behind_count: number;
}

export const checkIfIsEasyScenarioWhenCanAutoGenerateRewrittenList = (range_diffs: RangeDiff[]): EasyScenarioRet => {
let i = 0
const eq_from = i
while (i < range_diffs.length && range_diffs[i].eq_sign === "=") {
++i
}
const eq_till = i
const eq_count = eq_till - eq_from
const eq_indices: EasyScenarioRet["eq_indices"] = new Set()
const ahead_indices: EasyScenarioRet["ahead_indices"] = new Set()

// extra commits in diverged branch, that need to be integrated back into latest
const ahead_from = i
while (i < range_diffs.length && range_diffs[i].eq_sign === "<") {
++i
let i = 0
const isEq = () => range_diffs[i].eq_sign === "="
const isAhead = () => range_diffs[i].eq_sign === "<"
while (i < range_diffs.length) {
if (isEq()) {
eq_indices.add(i++)
} else if (isAhead()) {
ahead_indices.add(i++)
} else {
break
}
}
const ahead_till = i
const ahead_count = ahead_till - ahead_from

const behind_from = i
while (i < range_diffs.length && range_diffs[i].eq_sign === ">") {
Expand All @@ -361,13 +356,8 @@ export const checkIfIsEasyScenarioWhenCanAutoGenerateRewrittenList = (range_diff
return {
is_easy_repair_scenario,
//
eq_from,
eq_till,
eq_count,
//
ahead_from,
ahead_till,
ahead_count,
eq_indices,
ahead_indices,
//
behind_from,
behind_till,
Expand Down
22 changes: 20 additions & 2 deletions repair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,30 @@ export async function repair({
let repair_nth_sha: number = ref_repaired_sha_index.get(refname)!;
const incr_ref_sha_index = () => ref_repaired_sha_index.set(refname, ++repair_nth_sha);

const ref_already_finished: boolean = repair_nth_sha === ref.easy_repair_scenario.eq_count + 1;
const ref_already_finished: boolean = repair_nth_sha === ref.easy_repair_scenario.behind_from + 1; // TODO verify - idk if need + 1
if (ref_already_finished) {
continue;
}

const delta: RangeDiff = ref.range_diff_parsed[repair_nth_sha];

const isAhead = () => ref.range_diff_parsed[i].eq_sign === "<"
if (isAhead()) {
let delta_tmp: RangeDiff

Check failure on line 78 in repair.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 12, false)

'delta_tmp' is declared but its value is never read.

Check failure on line 78 in repair.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 14, false)

'delta_tmp' is declared but its value is never read.

Check failure on line 78 in repair.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 16, false)

'delta_tmp' is declared but its value is never read.

Check failure on line 78 in repair.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 14, false)

'delta_tmp' is declared but its value is never read.

Check failure on line 78 in repair.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 16, false)

'delta_tmp' is declared but its value is never read.

Check failure on line 78 in repair.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 12, true)

'delta_tmp' is declared but its value is never read.
while ((delta_tmp = ref.range_diff_parsed[i]) && isAhead()) {
const extraCommit: CommitAndBranchBoundary = {
commit: await Git.Commit.lookup(repo, delta.sha_after_full),
commitCommand: "pick",
branchEnd: null,
branchEndCommands: null,
};

insertCommit(extraCommit);
}

continue; // TODO: wat do if other refs want to be pointing to earlier sha, but we incremented `i`?
}

const old_sha_to_find: string = delta.sha_before_full;

const found_sha: boolean = bb_commit_sha === old_sha_to_find;
Expand Down Expand Up @@ -132,7 +150,7 @@ export async function repair({
incr_ref_sha_index();
}

const just_finished_ref: boolean = repair_nth_sha === ref.easy_repair_scenario.eq_count;
const just_finished_ref: boolean = repair_nth_sha === ref.easy_repair_scenario.behind_from;

if (just_finished_ref) {
refs_in_progress.delete(refname);
Expand Down

0 comments on commit ec91c5c

Please sign in to comment.