mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-26 07:00:38 +08:00
Fix regression in patches feature
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -17,11 +17,15 @@
|
||||
|
||||
onMount(async () => {
|
||||
if (author.profile?.ens?.name) {
|
||||
profile = await Profile.get(
|
||||
author.profile.ens.name,
|
||||
ProfileType.Minimal,
|
||||
wallet,
|
||||
);
|
||||
try {
|
||||
profile = await Profile.get(
|
||||
author.profile.ens.name,
|
||||
ProfileType.Minimal,
|
||||
wallet,
|
||||
);
|
||||
} catch {
|
||||
// Ignore profile not found.
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
+49
-6
@@ -143,18 +143,61 @@ export class Patch implements IPatch {
|
||||
}
|
||||
|
||||
static async getPatches(id: string, host: Host): Promise<Patch[]> {
|
||||
const response: IPatch[] = await new Request(
|
||||
`projects/${id}/patches`,
|
||||
host,
|
||||
).get();
|
||||
return response.map(patch => new Patch(patch));
|
||||
const response = await new Request(`projects/${id}/patches`, host).get();
|
||||
for (const patch of response) {
|
||||
patch.author["id"] = patch.author["urn"];
|
||||
delete patch.author["urn"];
|
||||
}
|
||||
|
||||
return response.map((patch: IPatch) => new Patch(patch));
|
||||
}
|
||||
|
||||
static async getPatch(id: string, patch: string, host: Host): Promise<Patch> {
|
||||
const response: IPatch = await new Request(
|
||||
const response = await new Request(
|
||||
`projects/${id}/patches/${patch}`,
|
||||
host,
|
||||
).get();
|
||||
|
||||
response.author["id"] = response.author["urn"];
|
||||
delete response.author["urn"];
|
||||
|
||||
for (const revision of response.revisions) {
|
||||
if (revision.changeset?.diff) {
|
||||
revision.changeset.diff["added"] = revision.changeset.diff["created"];
|
||||
delete revision.changeset.diff["created"];
|
||||
|
||||
revision.comment.author["id"] = revision.comment.author["urn"];
|
||||
delete revision.comment.author["urn"];
|
||||
|
||||
revision.changeset.stats["insertions"] =
|
||||
revision.changeset.stats["additions"];
|
||||
delete revision.changeset.stats["additions"];
|
||||
|
||||
for (const kind of ["added", "deleted", "modified"]) {
|
||||
for (const file of revision.changeset.diff[kind]) {
|
||||
for (const hunk of file.diff.hunks) {
|
||||
for (const line of hunk.lines) {
|
||||
if (line["lineNumOld"]) {
|
||||
line["lineNoOld"] = line["lineNumOld"];
|
||||
delete line["lineNumOld"];
|
||||
}
|
||||
|
||||
if (line["lineNumNew"]) {
|
||||
line["lineNoNew"] = line["lineNumNew"];
|
||||
delete line["lineNumNew"];
|
||||
}
|
||||
|
||||
if (line["lineNum"]) {
|
||||
line["lineNo"] = line["lineNum"];
|
||||
delete line["lineNum"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new Patch(response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user