Skip to content

Commit

Permalink
Merge pull request #1 from parthlr/v0.1.1-beta
Browse files Browse the repository at this point in the history
V0.1.1 beta Update
  • Loading branch information
parthlr authored Oct 27, 2024
2 parents 2fa2429 + 5d89033 commit c73fbec
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
15 changes: 13 additions & 2 deletions StardewValleyManager/Services/GitService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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"));

Expand Down Expand Up @@ -79,6 +86,7 @@ public async Task CheckAndCreateRepository(string RepositoryName)
if (r.Name.Equals(RepositoryName))
{
repoExists = true;
_branchName = r.DefaultBranch;
break;
}
}
Expand All @@ -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)
Expand Down Expand Up @@ -202,7 +213,7 @@ public async Task<string> GetCommitContent(string FileName, string CommitSha)

public async Task<Commit> 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);
Expand Down Expand Up @@ -255,7 +266,7 @@ private async Task<Reference> 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;
Expand Down
13 changes: 13 additions & 0 deletions StardewValleyManager/Views/SavesView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 () =>
Expand Down
1 change: 1 addition & 0 deletions StardewValleyManager/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<gitToken></gitToken>
<username></username>
<repository>StardewValleySaves</repository>
<defaultBranch></defaultBranch>
</settings>

0 comments on commit c73fbec

Please sign in to comment.