Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion ProjectDirector/ProjectDirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
using ktsu.ImGui.Widgets;
using ktsu.ImGui.Styler;
using Octokit;
// using OpenAI.Chat;

Check warning on line 22 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
using Semantics.Paths;

#pragma warning disable CA1506
Expand Down Expand Up @@ -62,7 +62,7 @@
/// </summary>
private CloneTracker Clones { get; } = new();

// private ChatClient ChatClient { get; init; }

Check warning on line 65 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.

private static void Main(string[] _) => ImGuiApp.Start(new ProjectDirector().BuildConfig());

Expand Down Expand Up @@ -101,7 +101,7 @@
_ = MakeLoadedOptionsSafe(Options, QueueLog);

Options.Save();
// ChatClient = new(model: "gpt-4o", new ApiKeyCredential(Options.OpenAIToken));

Check warning on line 104 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
DividerDiff = new("DiffDivider", DividerResized, ImGuiWidgets.DividerLayout.Columns);
DividerContainerCols = new("VerticalDivider", DividerResized, ImGuiWidgets.DividerLayout.Columns);
DividerContainerRows = new("HorizontalDivider", DividerResized, ImGuiWidgets.DividerLayout.Rows);
Expand Down Expand Up @@ -423,7 +423,7 @@
private void FetchAllRepos() => Options.ClonedRepos.Values.ForEach(FetchRepo);
private void PullAllRepos() => Options.ClonedRepos.Values.ForEach(PullRepo);

private void FetchRepo(FullyQualifiedGitHubRepoName repoName)

Check warning on line 426 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

All 'FetchRepo' method overloads should be adjacent.
{
if (Options.Repos.TryGetValue(repoName, out GitRepository? repo))
{
Expand Down Expand Up @@ -765,7 +765,7 @@
});
}

//int fetchInterval = repo.MinFetchIntervalSeconds;

Check warning on line 768 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
//if (ImGuiWidgets.Knob("Min Fetch Interval", ref fetchInterval, 0, 300, 150))
//{
// repo.MinFetchIntervalSeconds = fetchInterval;
Expand Down Expand Up @@ -894,7 +894,12 @@
ImGuiProbes.MarkItem("panel", name);
if (expanded)
{
// CollapsingHeader opens no ID scope of its own, so without this two panels drawing a widget
// with the same label (each owner's ".github" row) would give both the same ID, and ImGui would
// hand a click on the second to the first.
ImGui.PushID(name);
contentDelegate?.Invoke();
ImGui.PopID();
open = true;
}
else
Expand Down Expand Up @@ -1020,7 +1025,7 @@
ImGui.SameLine();
bool isSelected = Options.BaseRepo == repoName;
bool clicked = ImGui.Selectable(gitHubRepo.RepoName, ref isSelected);
ImGuiProbes.MarkItem("repo", gitHubRepo.RepoName);
ImGuiProbes.MarkItem("repo", repoName);
if (clicked)
{
SwitchPage(repoName);
Expand Down Expand Up @@ -2298,7 +2303,7 @@

if (ImGui.TableNextColumn())
{
//if (ImGui.Button($"Propagate Directory###Propagate{path.Replace(Path.DirectorySeparatorChar, '.').Replace(Path.AltDirectorySeparatorChar, '.')}"))

Check warning on line 2306 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
//{
// shouldOpenPopup |= true;
// Options.PropagatePath = path;
Expand All @@ -2307,7 +2312,7 @@

if (ImGui.TableNextColumn())
{
//if (ImGui.Button($"X"))

Check warning on line 2315 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
//{
// //Directory.Delete(Path.Combine(Options.Repos[Options.BaseRepo].LocalPath, Options.BrowsePath, path));
//}
Expand Down Expand Up @@ -2352,7 +2357,7 @@

}

// if (ImGui.Selectable($"Generate Readme"))

Check warning on line 2360 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
// {
// GitRepository repo = Options.Repos[Options.BaseRepo];
// IEnumerable<string> csFiles = Directory.EnumerateFiles(repo.LocalPath, "*.cs", SearchOption.AllDirectories);
Expand Down Expand Up @@ -2383,13 +2388,13 @@

if (ImGui.TableNextColumn())//&& ImGui.Button($"Propagate###Propagate{path.Replace(Path.DirectorySeparatorChar, '.').Replace(Path.AltDirectorySeparatorChar, '.')}"))
{
//shouldOpenPopup |= true;

Check warning on line 2391 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
//Options.PropagatePath = path;
}

if (ImGui.TableNextColumn())
{
//if (ImGui.Button($"X"))

Check warning on line 2397 in ProjectDirector/ProjectDirector.cs

View workflow job for this annotation

GitHub Actions / ci / .NET / Analyze & Release

Remove this commented out code.
//{
// //File.Delete(Path.Combine(Options.Repos[Options.BaseRepo].LocalPath, Options.BrowsePath, path));
//}
Expand Down
12 changes: 9 additions & 3 deletions tests/ProjectDirector.UITests/Gallery/GalleryApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,21 @@ private GalleryApp(ImGuiAppHarness harness, ProjectDirectorOptions options, Cred
/// <summary>Starts the application at the given display size.</summary>
/// <param name="display">The size of the window the application draws into.</param>
/// <returns>The running application.</returns>
internal static GalleryApp Start((int Width, int Height) display)
internal static GalleryApp Start((int Width, int Height) display) => Start(display, GalleryRepositories.CreateOptions);

/// <summary>Starts the application at the given display size over settings the caller builds.</summary>
/// <param name="display">The size of the window the application draws into.</param>
/// <param name="createOptions">Builds the settings the application runs on, after the settings file and secret store are redirected.</param>
/// <returns>The running application.</returns>
internal static GalleryApp Start((int Width, int Height) display, Func<ProjectDirectorOptions> createOptions)
{
AppData.ConfigureForTesting(() => new MockFileSystem());
CredentialCache credentials = new(new InMemoryCredentialStore());
TokenStorage.UseCache(credentials);

try
{
ProjectDirectorOptions options = GalleryRepositories.CreateOptions();
ProjectDirectorOptions options = createOptions();
ProjectDirector director = new(options);
ImGuiAppHarness harness = ImGuiAppHarness.Start(director.BuildConfig(), new HarnessOptions
{
Expand All @@ -68,7 +74,7 @@ internal static GalleryApp Start((int Width, int Height) display)
/// <param name="repo">The repository's own name.</param>
internal void SelectRepository(string repo)
{
Harness.Click($"repo/{repo}");
Harness.Click($"repo/{GalleryRepositories.FullName(repo)}");
GitRepository selected = Options.Repos[GalleryRepositories.FullName(repo)];

// The comparison runs git on a background task, which publishes whenever it finishes rather
Expand Down
64 changes: 64 additions & 0 deletions tests/ProjectDirector.UITests/RepoPanelTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) 2023-2026 ktsu-dev contributors

namespace ktsu.ProjectDirector.UITests;

using ktsu.ProjectDirector.UITests.Gallery;
using ktsu.Semantics.Paths;

/// <summary>
/// Drives the left panel's repository list, where every owner's repositories are drawn as rows of
/// the same kind of widget.
/// </summary>
[TestClass]
public sealed class RepoPanelTests
{
private const string SharedName = ".github";

private static readonly string[] Owners = ["ktsu-dev", "matt-edmondson"];

[TestMethod]
public void ClickingASharedRepoName_SelectsThatOwnersRepository()
{
using GalleryApp app = GalleryApp.Start(AppGallery.Display, CreateOptions);
app.Harness.Step(2);

// Click the later owner first: it is the row an ID clash with the earlier owner's row swallows.
foreach (string owner in Owners.Reverse())
{
FullyQualifiedGitHubRepoName expected = FullName(owner);
app.Harness.Click($"repo/{expected}");
app.Harness.Step(2);

Assert.AreEqual(expected, app.Options.BaseRepo, $"Clicking {owner}'s {SharedName} did not select it.");
}
}

private static FullyQualifiedGitHubRepoName FullName(string owner) =>
FullyQualifiedGitHubRepoName.Create<FullyQualifiedGitHubRepoName>($"{owner}.{SharedName}");

private static ProjectDirectorOptions CreateOptions()
{
// Nothing is cloned, so the paths are never created; they only have to differ per owner.
string root = Path.Combine(Path.GetTempPath(), "projectdirector-repo-panel");
ProjectDirectorOptions options = new()
{
DevDirectory = AbsoluteDirectoryPath.Create<AbsoluteDirectoryPath>(root),
};

foreach (string ownerName in Owners)
{
GitHubOwnerName owner = GitHubOwnerName.Create<GitHubOwnerName>(ownerName);
_ = options.GitHubOwners.Add(owner);
options.Repos[FullName(ownerName)] = new GitHubRepository()
{
OwnerName = owner,
RepoName = GitHubRepoName.Create<GitHubRepoName>(SharedName),
LocalPath = FullyQualifiedLocalRepoPath.Create<FullyQualifiedLocalRepoPath>(Path.Combine(root, ownerName, SharedName)),
RemotePath = GitRemotePath.Create<GitRemotePath>($"https://github.com/{ownerName}/{SharedName}"),
MinFetchIntervalSeconds = 0,
};
}

return options;
}
}
Loading