mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
Make conflict marking optional
This commit is contained in:
@@ -86,7 +86,8 @@ const ModifiedDiffComponent = styled(DiffComponent)`
|
|||||||
|
|
||||||
class DiffFile extends React.Component<Props, State> {
|
class DiffFile extends React.Component<Props, State> {
|
||||||
static defaultProps: Partial<Props> = {
|
static defaultProps: Partial<Props> = {
|
||||||
defaultCollapse: false
|
defaultCollapse: false,
|
||||||
|
markConflicts: true
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props: Props) {
|
constructor(props: Props) {
|
||||||
@@ -173,17 +174,8 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
renderHunk = (hunk: HunkType, i: number) => {
|
renderHunk = (hunk: HunkType, i: number) => {
|
||||||
let inConflict = false;
|
if (this.props.markConflicts) {
|
||||||
for (i = 0; i < hunk.changes.length; ++i) {
|
this.markConflicts(hunk);
|
||||||
if (hunk.changes[i].content === "<<<<<<< HEAD") {
|
|
||||||
inConflict = true;
|
|
||||||
}
|
|
||||||
if (inConflict) {
|
|
||||||
hunk.changes[i].type = "conflict";
|
|
||||||
}
|
|
||||||
if (hunk.changes[i].content.startsWith(">>>>>>>")) {
|
|
||||||
inConflict = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
<Decoration key={"decoration-" + hunk.content}>{this.createHunkHeader(hunk, i)}</Decoration>,
|
<Decoration key={"decoration-" + hunk.content}>{this.createHunkHeader(hunk, i)}</Decoration>,
|
||||||
@@ -196,6 +188,21 @@ class DiffFile extends React.Component<Props, State> {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
markConflicts = (hunk: HunkType) => {
|
||||||
|
let inConflict = false;
|
||||||
|
for (let i = 0; i < hunk.changes.length; ++i) {
|
||||||
|
if (hunk.changes[i].content === "<<<<<<< HEAD") {
|
||||||
|
inConflict = true;
|
||||||
|
}
|
||||||
|
if (inConflict) {
|
||||||
|
hunk.changes[i].type = "conflict";
|
||||||
|
}
|
||||||
|
if (hunk.changes[i].content.startsWith(">>>>>>>")) {
|
||||||
|
inConflict = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
renderFileTitle = (file: File) => {
|
renderFileTitle = (file: File) => {
|
||||||
if (file.oldPath !== file.newPath && (file.type === "copy" || file.type === "rename")) {
|
if (file.oldPath !== file.newPath && (file.type === "copy" || file.type === "rename")) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -75,4 +75,5 @@ export type DiffObjectProps = {
|
|||||||
fileControlFactory?: FileControlFactory;
|
fileControlFactory?: FileControlFactory;
|
||||||
fileAnnotationFactory?: FileAnnotationFactory;
|
fileAnnotationFactory?: FileAnnotationFactory;
|
||||||
annotationFactory?: AnnotationFactory;
|
annotationFactory?: AnnotationFactory;
|
||||||
|
markConflicts?: boolean;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user