mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-25 16:20:38 +08:00
Add commit detail view
Signed-off-by: Sebastian Martinez <sebastinez@me.com>
This commit is contained in:
+91
@@ -0,0 +1,91 @@
|
||||
export const lineNumberR = (line: LineDiff): string | number => {
|
||||
switch (line.type) {
|
||||
case LineDiffType.Addition: {
|
||||
return line.lineNum;
|
||||
}
|
||||
case LineDiffType.Context: {
|
||||
return line.lineNumNew;
|
||||
}
|
||||
case LineDiffType.Deletion: {
|
||||
return " ";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const lineNumberL = (line: LineDiff): string | number => {
|
||||
switch (line.type) {
|
||||
case LineDiffType.Addition: {
|
||||
return " ";
|
||||
}
|
||||
case LineDiffType.Context: {
|
||||
return line.lineNumOld;
|
||||
}
|
||||
case LineDiffType.Deletion: {
|
||||
return line.lineNum;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const lineSign = (line: LineDiff): string => {
|
||||
switch (line.type) {
|
||||
case LineDiffType.Addition: {
|
||||
return "+";
|
||||
}
|
||||
case LineDiffType.Context: {
|
||||
return " ";
|
||||
}
|
||||
case LineDiffType.Deletion: {
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export enum LineDiffType {
|
||||
Addition = "addition",
|
||||
Context = "context",
|
||||
Deletion = "deletion",
|
||||
}
|
||||
|
||||
export interface Addition {
|
||||
type: LineDiffType.Addition;
|
||||
line: string;
|
||||
lineNum: number;
|
||||
}
|
||||
|
||||
export interface Context {
|
||||
type: LineDiffType.Context;
|
||||
line: string;
|
||||
lineNumNew: number;
|
||||
lineNumOld: number;
|
||||
}
|
||||
|
||||
export interface Deletion {
|
||||
type: LineDiffType.Deletion;
|
||||
line: string;
|
||||
lineNum: number;
|
||||
}
|
||||
|
||||
export type LineDiff = Addition | Deletion | Context;
|
||||
|
||||
export interface FileDiff {
|
||||
path: string;
|
||||
diff: Changeset;
|
||||
}
|
||||
|
||||
export interface Changeset {
|
||||
type: string;
|
||||
hunks: Hunk[];
|
||||
}
|
||||
|
||||
export interface Hunk {
|
||||
header: string;
|
||||
lines: LineDiff[];
|
||||
}
|
||||
|
||||
export interface Diff {
|
||||
created: string[];
|
||||
deleted: string[];
|
||||
moved: string[];
|
||||
copied: string[];
|
||||
modified: FileDiff[];
|
||||
}
|
||||
Reference in New Issue
Block a user