Skip to content

Commit 4c160c8

Browse files
committed
Fixed duplicate line watcher default regex, added setting to include unchanged surrounding lines in watcher analysis
1 parent 841f6cd commit 4c160c8

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "light-git-client",
3-
"version": "0.4.3",
3+
"version": "0.4.4",
44
"description": "A light git client",
55
"author": {
66
"name": "Blake Stacks",

shared/SettingsModel.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {CodeWatcherModel} from './code-watcher.model';
22

33
const defaultCodeWatchers: CodeWatcherModel[] = [
4-
new CodeWatcherModel('Duplicate Lines', '^(.*)(\\r?\\n\\1)+$', 'g'),
4+
new CodeWatcherModel('Duplicate Lines', '(^|\\n)(.*)(\\r?\\n\\2(\\r?\\n|$))+', 'g'),
55
new CodeWatcherModel('Console Output', 'console\\.(log|error|info)', 'g', '\\.(ts|js|jsx)'),
66
];
77

@@ -19,6 +19,7 @@ export class SettingsModel {
1919
public expandStates: { [key: string]: boolean };
2020
public commandTimeoutSeconds: number;
2121
public codeWatchers: CodeWatcherModel[];
22+
public includeUnchangedInWatcherAnalysis: boolean;
2223

2324
constructor(darkMode: boolean = false,
2425
openRepos: string[] = [''],
@@ -32,6 +33,7 @@ export class SettingsModel {
3233
showTrackingPath: boolean = false,
3334
commitMessageAutcomplete: boolean = false,
3435
diffIgnoreWhitespace: boolean = false,
36+
includeUnchangedInWatcherAnalysis: boolean = true,
3537
codeWatchers: CodeWatcherModel[] = defaultCodeWatchers) {
3638
this.darkMode = darkMode;
3739
this.openRepos = openRepos;
@@ -46,6 +48,7 @@ export class SettingsModel {
4648
this.diffIgnoreWhitespace = diffIgnoreWhitespace;
4749
this.mergetool = mergetool;
4850
this.codeWatchers = codeWatchers;
51+
this.includeUnchangedInWatcherAnalysis = includeUnchangedInWatcherAnalysis;
4952
}
5053

5154
static sanitizePath(path) {
@@ -67,6 +70,7 @@ export class SettingsModel {
6770
res.commitMessageAutocomplete = this.commitMessageAutocomplete;
6871
res.diffIgnoreWhitespace = this.diffIgnoreWhitespace;
6972
res.mergetool = this.mergetool;
73+
res.includeUnchangedInWatcherAnalysis = this.includeUnchangedInWatcherAnalysis;
7074
return res;
7175
}
7276
}

src/app/components/code-watcher-alerts/code-watcher-alerts.component.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ export class CodeWatcherAlertsComponent implements OnInit {
4343
return {
4444
file: x.toFilename,
4545
hunks: x.hunks.map(h => {
46-
// TODO: decide whether or not to include only changed lines or surrounding lines too
47-
return {hunk: h, code: h.lines.filter(l => l.state != LineState.REMOVED).map(l => l.text).join('\n')};
46+
if (this.settingsService.settings.includeUnchangedInWatcherAnalysis) {
47+
return {hunk: h, code: h.lines.filter(l => l.state != LineState.REMOVED).map(l => l.text).join('\n')};
48+
} else {
49+
return {hunk: h, code: h.lines.filter(l => l.state == LineState.ADDED).map(l => l.text).join('\n')};
50+
}
4851
})
4952
};
5053
});

src/app/components/settings/settings.component.html

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ <h5 class="modal-title">Settings</h5>
6969
</div>
7070
<div *ngIf="currentTab==1">
7171
<p>Watch your code changes for specified patterns, and alert you before you commit</p>
72+
<div class="pretty p-switch p-fill mb-1 d-block">
73+
<input type="checkbox" [(ngModel)]="tempSettings.includeUnchangedInWatcherAnalysis"/>
74+
<div class="state">
75+
<label>Include Unchanged Surrounding Code in Analysis</label>
76+
</div>
77+
</div>
7278
<table class="table table-striped">
7379
<thead>
7480
<tr>

0 commit comments

Comments
 (0)