Skip to content

Commit 30b949e

Browse files
committed
remove IsValidDate
1 parent 1223402 commit 30b949e

File tree

4 files changed

+0
-62
lines changed

4 files changed

+0
-62
lines changed

GitContentSearch.Tests/GitHelperTests.cs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -340,39 +340,5 @@ public void GetGitCommitsByDate_ShouldReturnCommits_WhenDatesAreValid()
340340
Assert.Equal("commit5", result[0].CommitHash);
341341
Assert.Equal("commit1", result[4].CommitHash);
342342
}
343-
344-
[Fact]
345-
public void IsValidDate_ShouldReturnFalse_ForFutureDate()
346-
{
347-
// Arrange
348-
var processWrapperMock = new Mock<IProcessWrapper>();
349-
var gitHelper = new GitHelper(processWrapperMock.Object);
350-
var futureDate = DateTime.UtcNow.AddDays(1);
351-
352-
// Act
353-
var result = gitHelper.IsValidDate(futureDate);
354-
355-
// Assert
356-
Assert.False(result);
357-
}
358-
359-
[Theory]
360-
[InlineData(-1)] // Yesterday
361-
[InlineData(-100)] // 100 days ago
362-
[InlineData(-365)] // A year ago
363-
[InlineData(-3650)] // 10 years ago
364-
public void IsValidDate_ShouldReturnTrue_ForAnyPastDate(int daysToAdd)
365-
{
366-
// Arrange
367-
var processWrapperMock = new Mock<IProcessWrapper>();
368-
var gitHelper = new GitHelper(processWrapperMock.Object);
369-
var pastDate = DateTime.UtcNow.AddDays(daysToAdd);
370-
371-
// Act
372-
var result = gitHelper.IsValidDate(pastDate);
373-
374-
// Assert
375-
Assert.True(result);
376-
}
377343
}
378344
}

GitContentSearch/GitContentSearcher.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,6 @@ public void SearchContentByDate(string filePath, string searchString, DateTime?
171171
return;
172172
}
173173

174-
// Validate dates if provided
175-
if (startDate.HasValue && !_gitHelper.IsValidDate(startDate.Value))
176-
{
177-
_logger.WriteLine($"Error: Invalid start date: {startDate.Value:yyyy-MM-dd}");
178-
_progress?.Report(1.0);
179-
return;
180-
}
181-
182-
if (endDate.HasValue && !_gitHelper.IsValidDate(endDate.Value))
183-
{
184-
_logger.WriteLine($"Error: Invalid end date: {endDate.Value:yyyy-MM-dd}");
185-
_progress?.Report(1.0);
186-
return;
187-
}
188-
189174
if (startDate.HasValue && endDate.HasValue && startDate.Value > endDate.Value)
190175
{
191176
_logger.WriteLine($"Error: Start date ({startDate.Value:yyyy-MM-dd}) is later than end date ({endDate.Value:yyyy-MM-dd})");

GitContentSearch/GitHelper.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -393,18 +393,6 @@ public List<Commit> GetGitCommitsByDate(DateTime? startDate, DateTime? endDate,
393393
return commits;
394394
}
395395

396-
public bool IsValidDate(DateTime date)
397-
{
398-
// Only check if the date is not in the future
399-
if (date > DateTime.UtcNow)
400-
{
401-
_logger?.WriteLine($"Error: Date {date:yyyy-MM-dd} is in the future.");
402-
return false;
403-
}
404-
405-
return true;
406-
}
407-
408396
private void EnsureRepositoryInitialized()
409397
{
410398
if (_repository == null)

GitContentSearch/Interfaces/IGitHelper.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ public interface IGitHelper : IDisposable
1717
List<Commit> GetGitCommits(string earliestCommit, string latestCommit, string filePath, CancellationToken cancellationToken);
1818
List<Commit> GetGitCommitsByDate(DateTime? startDate, DateTime? endDate, string filePath = "");
1919
List<Commit> GetGitCommitsByDate(DateTime? startDate, DateTime? endDate, string filePath, CancellationToken cancellationToken);
20-
bool IsValidDate(DateTime date);
2120
}
2221
}

0 commit comments

Comments
 (0)