Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Windows
pEp for Outlook
Commits
d155fc28
Commit
d155fc28
authored
Sep 17, 2021
by
Thomas
Browse files
Remove root directory in file paths in diffs
parent
3b75ee9d
Changes
1
Hide whitespace changes
Inline
Side-by-side
UI/ViewModels/PatchDialogViewModel.cs
View file @
d155fc28
...
@@ -25,6 +25,9 @@ namespace pEp.UI.ViewModels
...
@@ -25,6 +25,9 @@ namespace pEp.UI.ViewModels
private
ConfigFile
_SelectedFile
=
null
;
private
ConfigFile
_SelectedFile
=
null
;
private
FlowDocument
_VisibleDiff
=
null
;
private
FlowDocument
_VisibleDiff
=
null
;
private
const
string
FILE_A_PREFIX
=
"---a"
;
private
const
string
FILE_B_PREFIX
=
"+++b"
;
#
endregion
#
endregion
#
region
Properties
#
region
Properties
...
@@ -289,12 +292,12 @@ namespace pEp.UI.ViewModels
...
@@ -289,12 +292,12 @@ namespace pEp.UI.ViewModels
// The patch was created right now
// The patch was created right now
this
.
Dialog
.
Patch
.
CreationDate
=
DateTime
.
UtcNow
;
this
.
Dialog
.
Patch
.
CreationDate
=
DateTime
.
UtcNow
;
// Concatenate all diffs from the selected files
this
.
Dialog
.
Patch
.
Diff
=
this
.
UnifyDiffs
();
// Get a common root URI of all diff files
// Get a common root URI of all diff files
this
.
Dialog
.
Patch
.
Uri
=
this
.
GetRootUri
();
this
.
Dialog
.
Patch
.
Uri
=
this
.
GetRootUri
();
// Concatenate all diffs from the selected files
this
.
Dialog
.
Patch
.
Diff
=
this
.
UnifyDiffs
();
// Close with result True.
// Close with result True.
this
.
Close
(
true
);
this
.
Close
(
true
);
}
}
...
@@ -363,7 +366,7 @@ namespace pEp.UI.ViewModels
...
@@ -363,7 +366,7 @@ namespace pEp.UI.ViewModels
* => The modified part.
* => The modified part.
* => Three unchanged lines (if available) after the modified part.
* => Three unchanged lines (if available) after the modified part.
*/
*/
string
diff
=
$"
---a/
{
fileNameB
}
\n+++b
/
{
fileNameB
}
\n"
;
string
diff
=
$"
{
PatchDialogViewModel
.
FILE_A_PREFIX
}
/
{
fileNameB
}
\n
{
PatchDialogViewModel
.
FILE_B_PREFIX
}
/
{
fileNameB
}
\n"
;
SideBySideDiffModel
sideBySideDiffModel
=
SideBySideDiffBuilder
.
Diff
(
fileA
,
fileB
);
SideBySideDiffModel
sideBySideDiffModel
=
SideBySideDiffBuilder
.
Diff
(
fileA
,
fileB
);
List
<
DiffPiece
>
newLines
=
sideBySideDiffModel
.
NewText
.
Lines
;
List
<
DiffPiece
>
newLines
=
sideBySideDiffModel
.
NewText
.
Lines
;
...
@@ -587,11 +590,16 @@ namespace pEp.UI.ViewModels
...
@@ -587,11 +590,16 @@ namespace pEp.UI.ViewModels
{
{
string
diff
=
null
;
string
diff
=
null
;
// Concatenate diffs
foreach
(
ConfigFile
modifiedFile
in
this
.
ConfigFiles
)
foreach
(
ConfigFile
modifiedFile
in
this
.
ConfigFiles
)
{
{
diff
+=
modifiedFile
.
Diff
+
"\n"
;
diff
+=
modifiedFile
.
Diff
+
"\n"
;
}
}
// Remove root parts of URI
diff
=
diff
.
Replace
(
PatchDialogViewModel
.
FILE_A_PREFIX
+
"/"
+
this
.
Dialog
.
Patch
.
Uri
,
PatchDialogViewModel
.
FILE_A_PREFIX
+
"/"
);
diff
=
diff
.
Replace
(
PatchDialogViewModel
.
FILE_B_PREFIX
+
"/"
+
this
.
Dialog
.
Patch
.
Uri
,
PatchDialogViewModel
.
FILE_B_PREFIX
+
"/"
);
return
diff
.
TrimEnd
(
'\n'
);
return
diff
.
TrimEnd
(
'\n'
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment