From e6e38c81ad7f52a2d7400e674d903c06a826a2d3 Mon Sep 17 00:00:00 2001 From: parthlr Date: Sun, 27 Oct 2024 00:53:54 -0400 Subject: [PATCH 1/2] Fixed default branch assumption --- StardewValleyManager/Services/GitService.cs | 15 +++++++++++++-- StardewValleyManager/settings.xml | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/StardewValleyManager/Services/GitService.cs b/StardewValleyManager/Services/GitService.cs index 426b957..7e839ca 100644 --- a/StardewValleyManager/Services/GitService.cs +++ b/StardewValleyManager/Services/GitService.cs @@ -19,13 +19,20 @@ public class GitService private string _clientID; + private string _branchName; + + private SettingsService _settingsService; + public GitService(SettingsService settingsService) { + _settingsService = settingsService; + AuthToken = settingsService.GetSettingsValue("gitToken"); User = settingsService.GetSettingsValue("username"); RepositoryName = settingsService.GetSettingsValue("repository"); _clientID = settingsService.GetSettingsValue("clientID"); + _branchName = settingsService.GetSettingsValue("defaultBranch"); Client = new GitHubClient(new ProductHeaderValue("StardewValleyManager")); @@ -79,6 +86,7 @@ public async Task CheckAndCreateRepository(string RepositoryName) if (r.Name.Equals(RepositoryName)) { repoExists = true; + _branchName = r.DefaultBranch; break; } } @@ -92,12 +100,15 @@ public async Task CheckAndCreateRepository(string RepositoryName) Private = false }; Repository context = await Client.Repository.Create(newRepository); + _branchName = context.DefaultBranch; System.Diagnostics.Debug.WriteLine($"New repository {RepositoryName} was created for user {User}"); } else { System.Diagnostics.Debug.WriteLine($"Repository {RepositoryName} already exists for user {User}"); } + + _settingsService.UpdateSettingsValue("defaultBranch", _branchName, true); } public async Task CommitAllSaves(string[] Saves) @@ -202,7 +213,7 @@ public async Task GetCommitContent(string FileName, string CommitSha) public async Task GetLatestCommit() { - string branchHead = "heads/master"; + string branchHead = $"heads/{_branchName}"; Reference headReference = await Client.Git.Reference.Get(User, RepositoryName, branchHead); Commit latestCommit = await Client.Git.Commit.Get(User, RepositoryName, headReference.Object.Sha); @@ -255,7 +266,7 @@ private async Task CreateNewCommit(string CommitMessage, Commit Lates Commit commitResponse = await Client.Git.Commit.Create(User, RepositoryName, newCommit); - string branchHead = "heads/master"; + string branchHead = $"heads/{_branchName}"; Reference savedReference = await Client.Git.Reference.Update(User, RepositoryName, branchHead, new ReferenceUpdate(commitResponse.Sha)); return savedReference; diff --git a/StardewValleyManager/settings.xml b/StardewValleyManager/settings.xml index 31a1a10..693638b 100644 --- a/StardewValleyManager/settings.xml +++ b/StardewValleyManager/settings.xml @@ -6,4 +6,5 @@ StardewValleySaves + From 5d890336d54353f0029e18bfde99acb94840d1d1 Mon Sep 17 00:00:00 2001 From: parthlr Date: Sun, 27 Oct 2024 01:36:48 -0400 Subject: [PATCH 2/2] Fixed history table not showing row group headers on reload --- StardewValleyManager/Views/SavesView.axaml.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/StardewValleyManager/Views/SavesView.axaml.cs b/StardewValleyManager/Views/SavesView.axaml.cs index 733b337..8359ea6 100644 --- a/StardewValleyManager/Views/SavesView.axaml.cs +++ b/StardewValleyManager/Views/SavesView.axaml.cs @@ -19,6 +19,19 @@ public SavesView() InitializeComponent(); } + protected override void OnLoaded(RoutedEventArgs e) + { + base.OnLoaded(e); + + SaveHistoryTable.ItemsSource = new DataGridCollectionView(SaveHistoryTable.ItemsSource) + { + GroupDescriptions = + { + new DataGridPathGroupDescription("SaveSource") + } + }; + } + private void OpenSaveDetails(object? sender, RoutedEventArgs e) { Dispatcher.UIThread.Post(async () =>