mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-11 09:40:34 +08:00
Organise files more consistently
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
@@ -0,0 +1,98 @@
|
||||
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;
|
||||
eof: EofNewLine | null;
|
||||
}
|
||||
|
||||
export interface Changeset {
|
||||
type: string;
|
||||
hunks: Hunk[];
|
||||
}
|
||||
|
||||
export interface Hunk {
|
||||
header: string;
|
||||
lines: LineDiff[];
|
||||
}
|
||||
|
||||
export interface Diff {
|
||||
created: FileDiff[];
|
||||
deleted: FileDiff[];
|
||||
moved: string[];
|
||||
copied: string[];
|
||||
modified: FileDiff[];
|
||||
}
|
||||
|
||||
export enum EofNewLine {
|
||||
OldMissing = "oldMissing",
|
||||
NewMissing = "newMissing",
|
||||
BothMissing = "bothMissing",
|
||||
}
|
||||
Reference in New Issue
Block a user