mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-17 23:53:41 -10:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd0c8a9f05 | ||
|
|
13e18af777 | ||
|
|
488e819b46 | ||
|
|
ad8df8fe00 |
No files matched your search
@@ -172,6 +172,20 @@ test("accepting a deleted version removes the file before staging", async ({ pag
|
||||
]);
|
||||
});
|
||||
|
||||
test("a long side shows only the lines it changed against the base", async ({ page }) => {
|
||||
// Edits spread over a long file make the default diff give up and mark everything between them.
|
||||
const base = Array.from({ length: 2000 }, (_, i) => `"node_modules/pkg-${i}": "1.0.${i}",`);
|
||||
const bump = (at: number) => lines(...base.map((l, i) => (i % 100 === at ? l.replace('"1.0.', '"2.0.') : l)));
|
||||
await mountMerge(page, [lines(...base), bump(3), bump(50)]);
|
||||
for (const [name, line] of [
|
||||
["Your version", 3],
|
||||
["Their version", 50],
|
||||
] as const) {
|
||||
const deleted = page.getByRole("region", { name }).locator(".cm-deletedChunk").first().locator(".cm-deletedLine");
|
||||
await expect(deleted).toHaveText([base[line]!]);
|
||||
}
|
||||
});
|
||||
|
||||
test("the result starts as the base and every change waits for a decision", async ({ page }) => {
|
||||
await mountMerge(page);
|
||||
await expect(status(page)).toHaveText("3 changes left, 2 conflicts");
|
||||
|
||||
@@ -401,6 +401,9 @@ describe("pull request helpers", () => {
|
||||
"ssh://[email protected]/o/r.git",
|
||||
"ssh://[email protected]:22/o/r.git",
|
||||
"git://github.com/o/r",
|
||||
// GitHub's SSH-over-HTTPS host.
|
||||
"ssh://[email protected]:443/o/r.git",
|
||||
"[email protected]:o/r.git",
|
||||
])
|
||||
expect(parseGitHubRemote(url), url).toEqual({ owner: "o", name: "r" });
|
||||
expect(parseGitHubRemote("https://gitlab.com/o/r.git")).toBeNull();
|
||||
|
||||
@@ -413,10 +413,10 @@ export function repositoryDisplayName(
|
||||
return showOwner ? `${repo.owner}/${repo.name}` : repo.name;
|
||||
}
|
||||
|
||||
/** `owner/name` of a github.com remote URL (https, ssh or scp-like), else null. */
|
||||
/** `owner/name` of a github.com remote URL (https, ssh or scp-like; SSH also via ssh.github.com), else null. */
|
||||
export function parseGitHubRemote(url: string): GHRepositoryCoordinates | null {
|
||||
const m =
|
||||
/^(?:https?:\/\/(?:[^@/]+@)?|ssh:\/\/(?:[^@/]+@)?|git:\/\/|(?:[^@/]+@)?)(?:www\.)?github\.com(?::\d+(?=\/))?[:/]+([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(
|
||||
/^(?:(?:https?:\/\/(?:[^@/]+@)?|git:\/\/)(?:www\.)?|(?:ssh:\/\/(?:[^@/]+@)?|(?:[^@/]+@)?)(?:www\.|ssh\.)?)github\.com(?::\d+(?=\/))?[:/]+([^/]+)\/([^/]+?)(?:\.git)?\/?$/i.exec(
|
||||
url.trim(),
|
||||
);
|
||||
return m ? { owner: m[1]!, name: m[2]! } : null;
|
||||
|
||||
@@ -15,6 +15,7 @@ import { Button, Spinner, T } from "@/ui";
|
||||
import { editorService, type EditorInput } from "@/workbench/contributions";
|
||||
import { blameSlot, toggleAnnotations } from "./blame";
|
||||
import { languageFor, viewerBase } from "./cm";
|
||||
import { ideaDiffConfig } from "./diffOptions";
|
||||
import { confirmDialog } from "./dialogs";
|
||||
import { focusedDiffNavigator, setFocusedDiffNavigator, type DiffNavigator } from "./diffNavigator";
|
||||
import { syncMergeScroll } from "./mergeScroll";
|
||||
@@ -92,6 +93,10 @@ const writeAutoApply = (on: boolean) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Each side against the base is compared line by line, as in the diff viewer. The default diff
|
||||
// gives up on long files and marks the whole file as one changed block.
|
||||
const SIDE_DIFF = ideaDiffConfig("none", "words");
|
||||
|
||||
export function MergeEditor({ input }: { input: EditorInput }) {
|
||||
const { path } = input.data as MergeData;
|
||||
const [state, setState] = useState<{
|
||||
@@ -176,7 +181,9 @@ export function MergeEditor({ input }: { input: EditorInput }) {
|
||||
EditorView.updateListener.of((u) => {
|
||||
if (u.selectionSet) refreshMergeActions(actionHost);
|
||||
}),
|
||||
state.base !== null ? unifiedMergeView({ original: state.base, mergeControls: false, gutter: true }) : [],
|
||||
state.base !== null
|
||||
? unifiedMergeView({ original: state.base, mergeControls: false, gutter: true, diffConfig: SIDE_DIFF })
|
||||
: [],
|
||||
sideControls(which, controls),
|
||||
mergeStripe(which),
|
||||
mergeTheme,
|
||||
|
||||
@@ -7,6 +7,8 @@ describe("remoteHosting", () => {
|
||||
["https://github.example.com/o/r", "GitHub", "github"],
|
||||
["https://gitee.com/o/r.git", "Gitee", "github"],
|
||||
["[email protected]:o/r.git", "Bitbucket", "bitbucket"],
|
||||
["[email protected]:team/repo.git", "Bitbucket", "bitbucket"],
|
||||
["[email protected]:o/r.git", "GitHub", "github"],
|
||||
["ssh://[email protected]:2222/group/sub/r.git", "GitLab", "gitlab"],
|
||||
["[email protected]:group/r.git", "git.example.com", "gitlab"],
|
||||
])("%s → %s", (url, name, kind) => {
|
||||
@@ -43,4 +45,10 @@ describe("fileWebUrl", () => {
|
||||
"https://bitbucket.org/o/r/src/main/a.py#lines-5",
|
||||
);
|
||||
});
|
||||
|
||||
it("opens a Bitbucket Cloud SSH clone on bitbucket.org, not the SSH front host (#3372)", () => {
|
||||
expect(fileWebUrl("[email protected]:team/repo.git", "main", "a.py", { line: 4 })).toBe(
|
||||
"https://bitbucket.org/team/repo/src/main/a.py#lines-5",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import { Chunk } from "@codemirror/merge";
|
||||
import type { Text } from "@codemirror/state";
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import { bandAt, docOffset, extent, transferY } from "./diffScroll";
|
||||
import { ideaDiffConfig } from "./diffOptions";
|
||||
|
||||
export type MergePane = "ours" | "result" | "theirs";
|
||||
const PANES: readonly MergePane[] = ["ours", "result", "theirs"];
|
||||
@@ -32,6 +33,10 @@ export class ScrollEchoes<K> {
|
||||
}
|
||||
}
|
||||
|
||||
// Lined up by IDEA's line comparison. `Chunk.build` with no config runs an unbounded
|
||||
// character diff, which takes minutes on a long file such as a lockfile.
|
||||
const LINES = ideaDiffConfig("none", "lines");
|
||||
|
||||
/** Starts scrolling `views` together; returns the function that stops it. */
|
||||
export function syncMergeScroll(views: Record<MergePane, EditorView>): () => void {
|
||||
const built = new Map<MergePane, { a: Text; b: Text; chunks: readonly Chunk[] }>();
|
||||
@@ -40,7 +45,7 @@ export function syncMergeScroll(views: Record<MergePane, EditorView>): () => voi
|
||||
const b = views.result.state.doc;
|
||||
const hit = built.get(side);
|
||||
if (hit && hit.a === a && hit.b === b) return hit.chunks;
|
||||
const fresh = Chunk.build(a, b);
|
||||
const fresh = Chunk.build(a, b, LINES);
|
||||
built.set(side, { a, b, chunks: fresh });
|
||||
return fresh;
|
||||
};
|
||||
|
||||
@@ -139,6 +139,13 @@ export function stashLabel(message: string): { branch: string | null; text: stri
|
||||
return { branch: m[1]!, text: m[2]!.trim() || message };
|
||||
}
|
||||
|
||||
/** SSH front hosts that serve the same service as the web host in the value. */
|
||||
const WEB_HOST_ALIASES: Record<string, string> = {
|
||||
"ssh.bitbucket.org": "bitbucket.org",
|
||||
"ssh.github.com": "github.com",
|
||||
"altssh.gitlab.com": "gitlab.com",
|
||||
};
|
||||
|
||||
/**
|
||||
* Web page of a git remote URL (`[email protected]:o/r.git`, `ssh://git@host:22/o/r`,
|
||||
* `https://user@host/o/r.git`), or null for local paths.
|
||||
@@ -155,6 +162,7 @@ export function remoteWebUrl(url: string): string | null {
|
||||
if (full) [, host, path] = full as unknown as [string, string, string];
|
||||
else if (scp) [, host, path] = scp as unknown as [string, string, string];
|
||||
else return null;
|
||||
host = WEB_HOST_ALIASES[host.toLowerCase()] ?? host;
|
||||
return `https://${host}/${path.replace(/^\/+/, "")}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user