Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 77ee03b

Browse files
Removing extra call to OnHeadUpdated
2 parents e47cfac + 2a06427 commit 77ee03b

File tree

2 files changed

+20
-39
lines changed

2 files changed

+20
-39
lines changed

src/GitHub.Api/Events/RepositoryWatcher.cs

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface IRepositoryWatcher : IDisposable
1111
{
1212
void Start();
1313
void Stop();
14-
event Action<string> HeadChanged;
14+
event Action HeadChanged;
1515
event Action IndexChanged;
1616
event Action ConfigChanged;
1717
event Action<string> LocalBranchChanged;
@@ -38,7 +38,7 @@ class RepositoryWatcher : IRepositoryWatcher
3838
private bool processingEvents;
3939
private readonly ManualResetEventSlim signalProcessingEventsDone = new ManualResetEventSlim(false);
4040

41-
public event Action<string> HeadChanged;
41+
public event Action HeadChanged;
4242
public event Action IndexChanged;
4343
public event Action ConfigChanged;
4444
public event Action<string> LocalBranchChanged;
@@ -168,8 +168,6 @@ private int ProcessEvents(Event[] fileEvents)
168168
var repositoryChanged = false;
169169
var indexChanged = false;
170170

171-
string headContent = null;
172-
173171
foreach (var fileEvent in fileEvents)
174172
{
175173
if (!running)
@@ -200,19 +198,26 @@ private int ProcessEvents(Event[] fileEvents)
200198
if (!configChanged && fileA.Equals(paths.DotGitConfig))
201199
{
202200
configChanged = true;
201+
202+
Logger.Trace("ConfigChanged");
203+
ConfigChanged?.Invoke();
204+
eventsProcessed++;
203205
}
204206
else if (!headChanged && fileA.Equals(paths.DotGitHead))
205207
{
206-
if (fileEvent.Type != EventType.DELETED)
207-
{
208-
headContent = paths.DotGitHead.ReadAllLines().FirstOrDefault();
209-
}
210-
211208
headChanged = true;
209+
210+
Logger.Trace("HeadChanged");
211+
HeadChanged?.Invoke();
212+
eventsProcessed++;
212213
}
213214
else if (!indexChanged && fileA.Equals(paths.DotGitIndex))
214215
{
215216
indexChanged = true;
217+
218+
Logger.Trace("IndexChanged");
219+
IndexChanged?.Invoke();
220+
eventsProcessed++;
216221
}
217222
else if (fileA.IsChildOf(paths.RemotesPath))
218223
{
@@ -349,35 +354,11 @@ private int ProcessEvents(Event[] fileEvents)
349354
}
350355

351356
repositoryChanged = true;
352-
}
353-
}
354-
355-
if (configChanged)
356-
{
357-
Logger.Trace("ConfigChanged");
358-
ConfigChanged?.Invoke();
359-
eventsProcessed++;
360-
}
361-
362-
if (headChanged)
363-
{
364-
Logger.Trace("HeadChanged: {0}", headContent ?? "[null]");
365-
HeadChanged?.Invoke(headContent);
366-
eventsProcessed++;
367-
}
368357

369-
if (indexChanged)
370-
{
371-
Logger.Trace("IndexChanged");
372-
IndexChanged?.Invoke();
373-
eventsProcessed++;
374-
}
375-
376-
if (repositoryChanged)
377-
{
378-
Logger.Trace("RepositoryChanged");
379-
RepositoryChanged?.Invoke();
380-
eventsProcessed++;
358+
Logger.Trace("RepositoryChanged");
359+
RepositoryChanged?.Invoke();
360+
eventsProcessed++;
361+
}
381362
}
382363

383364
return eventsProcessed;

src/GitHub.Api/Git/RepositoryManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,10 @@ private void Watcher_OnConfigChanged()
413413
UpdateConfigData(true);
414414
}
415415

416-
private void Watcher_OnHeadChanged(string contents)
416+
private void Watcher_OnHeadChanged()
417417
{
418418
Logger.Trace("Watcher_OnHeadChanged");
419-
OnHeadUpdated?.Invoke(contents);
419+
UpdateHead();
420420
UpdateGitStatus();
421421
}
422422

0 commit comments

Comments
 (0)