diff --git a/src/Models/RepositorySettings.cs b/src/Models/RepositorySettings.cs
index 4cc1e3778..cbb93cc02 100644
--- a/src/Models/RepositorySettings.cs
+++ b/src/Models/RepositorySettings.cs
@@ -18,6 +18,12 @@ public string DefaultRemote
set;
} = string.Empty;
+ public string ProfileName
+ {
+ get;
+ set;
+ } = string.Empty;
+
public int PreferredMergeMode
{
get;
diff --git a/src/Models/UserProfile.cs b/src/Models/UserProfile.cs
new file mode 100644
index 000000000..ee232216a
--- /dev/null
+++ b/src/Models/UserProfile.cs
@@ -0,0 +1,43 @@
+using Avalonia.Collections;
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace SourceGit.Models
+{
+
+
+ public record UserProfileTargetFile(string File, Commit Revision);
+
+
+ public class UserProfile : ObservableObject
+ {
+ public string ProfileName
+ {
+ get => _profileName;
+ set => SetProperty(ref _profileName, value);
+ }
+
+ public string UserName
+ {
+ get => _userName;
+ set => SetProperty(ref _userName, value);
+ }
+
+ public string Email
+ {
+ get => _email;
+ set => SetProperty(ref _email, value);
+ }
+
+ public string Key
+ {
+ get => _key;
+ set => SetProperty(ref _key, value);
+ }
+
+
+ private string _profileName = string.Empty;
+ private string _userName = string.Empty;
+ private string _email = string.Empty;
+ private string _key = string.Empty;
+ }
+}
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index a14c66a16..6f87116d1 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -243,6 +243,7 @@
Minute(s)
Conventional Commit Types
Default Remote
+ User Profile
Preferred Merge Mode
ISSUE TRACKER
Add Azure DevOps Rule
@@ -266,6 +267,11 @@
HTTP proxy used by this repository
User Name
User name for this repository
+ USER PROFILE
+ Profile Name
+ User Name
+ Email Address
+ User Signing Key
Edit Custom Action Controls
Checked Value:
When checked, this value will be used in command-line arguments
diff --git a/src/ViewModels/Preferences.cs b/src/ViewModels/Preferences.cs
index 04ffbeb9d..d4be961f3 100644
--- a/src/ViewModels/Preferences.cs
+++ b/src/ViewModels/Preferences.cs
@@ -493,6 +493,12 @@ public AvaloniaList CustomActions
set;
} = [];
+ public AvaloniaList UserProfiles
+ {
+ get;
+ set;
+ } = [];
+
public AvaloniaList OpenAIServices
{
get;
diff --git a/src/ViewModels/RepositoryConfigure.cs b/src/ViewModels/RepositoryConfigure.cs
index 4a129e630..79746b90a 100644
--- a/src/ViewModels/RepositoryConfigure.cs
+++ b/src/ViewModels/RepositoryConfigure.cs
@@ -1,9 +1,13 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Threading.Tasks;
using Avalonia.Collections;
+using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
+using SourceGit.Models;
+using SourceGit.Views;
namespace SourceGit.ViewModels
{
@@ -26,6 +30,11 @@ public List Remotes
get;
}
+ public List UserProfileNames
+ {
+ get;
+ }
+
public string DefaultRemote
{
get => _repo.Settings.DefaultRemote;
@@ -39,6 +48,25 @@ public string DefaultRemote
}
}
+ public string ProfileName
+ {
+ set
+ {
+ foreach(var profile in _profiles)
+ {
+ if (profile.ProfileName == value)
+ {
+ UserName = profile.UserName;
+ UserEmail = profile.Email;
+ GPGUserSigningKey = profile.Key;
+ OnPropertyChanged(nameof(UserName));
+ OnPropertyChanged(nameof(UserEmail));
+ OnPropertyChanged(nameof(GPGUserSigningKey));
+ }
+ }
+ }
+ }
+
public int PreferredMergeMode
{
get => _repo.Settings.PreferredMergeMode;
@@ -154,6 +182,15 @@ public RepositoryConfigure(Repository repo)
foreach (var remote in _repo.Remotes)
Remotes.Add(remote.Name);
+ UserProfileNames = new List();
+ _profiles = new List();
+ foreach (var profile in Preferences.Instance.UserProfiles)
+ {
+ UserProfileNames.Add(profile.ProfileName);
+ _profiles.Add(profile);
+ }
+
+
AvailableOpenAIServices = new List() { "---" };
foreach (var service in Preferences.Instance.OpenAIServices)
AvailableOpenAIServices.Add(service.Name);
@@ -346,5 +383,10 @@ private async Task ApplyIssueTrackerChangesAsync()
private Models.CommitTemplate _selectedCommitTemplate = null;
private Models.IssueTracker _selectedIssueTracker = null;
private Models.CustomAction _selectedCustomAction = null;
+
+ public List _profiles
+ {
+ get;
+ }
}
}
diff --git a/src/Views/Preferences.axaml b/src/Views/Preferences.axaml
index 3b2ee062b..c2283fbe1 100644
--- a/src/Views/Preferences.axaml
+++ b/src/Views/Preferences.axaml
@@ -428,6 +428,118 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/Preferences.axaml.cs b/src/Views/Preferences.axaml.cs
index 28cdf901c..aab84ff1a 100644
--- a/src/Views/Preferences.axaml.cs
+++ b/src/Views/Preferences.axaml.cs
@@ -113,6 +113,15 @@ public Models.CustomAction SelectedCustomAction
set => SetValue(SelectedCustomActionProperty, value);
}
+ public static readonly StyledProperty SelectedUserProfileProperty =
+ AvaloniaProperty.Register(nameof(SelectedUserProfile));
+
+ public Models.UserProfile SelectedUserProfile
+ {
+ get => GetValue(SelectedUserProfileProperty);
+ set => SetValue(SelectedUserProfileProperty, value);
+ }
+
public Preferences()
{
var pref = ViewModels.Preferences.Instance;
@@ -495,6 +504,49 @@ private async void EditCustomActionControls(object sender, RoutedEventArgs e)
e.Handled = true;
}
+ private void OnAddUserProfile(object sender, RoutedEventArgs e)
+ {
+ var action = new Models.UserProfile() { ProfileName = "New Profile" };
+ ViewModels.Preferences.Instance.UserProfiles.Add(action);
+ SelectedUserProfile = action;
+
+ e.Handled = true;
+ }
+
+ private void OnRemoveSelectedUserProfile(object sender, RoutedEventArgs e)
+ {
+ if (SelectedUserProfile == null)
+ return;
+
+ ViewModels.Preferences.Instance.UserProfiles.Remove(SelectedUserProfile);
+ SelectedUserProfile = null;
+ e.Handled = true;
+ }
+
+ private void OnMoveSelectedUserProfileUp(object sender, RoutedEventArgs e)
+ {
+ if (SelectedUserProfile == null)
+ return;
+
+ var idx = ViewModels.Preferences.Instance.UserProfiles.IndexOf(SelectedUserProfile);
+ if (idx > 0)
+ ViewModels.Preferences.Instance.UserProfiles.Move(idx - 1, idx);
+
+ e.Handled = true;
+ }
+
+ private void OnMoveSelectedUserProfileDown(object sender, RoutedEventArgs e)
+ {
+ if (SelectedUserProfile == null)
+ return;
+
+ var idx = ViewModels.Preferences.Instance.UserProfiles.IndexOf(SelectedUserProfile);
+ if (idx < ViewModels.Preferences.Instance.UserProfiles.Count - 1)
+ ViewModels.Preferences.Instance.UserProfiles.Move(idx + 1, idx);
+
+ e.Handled = true;
+ }
+
private void UpdateGitVersion()
{
GitVersion = Native.OS.GitVersionString;
diff --git a/src/Views/RepositoryConfigure.axaml b/src/Views/RepositoryConfigure.axaml
index d08052fc5..ef9645c3a 100644
--- a/src/Views/RepositoryConfigure.axaml
+++ b/src/Views/RepositoryConfigure.axaml
@@ -44,7 +44,7 @@
-
+
@@ -62,6 +63,7 @@
@@ -143,6 +145,7 @@
@@ -179,6 +182,25 @@
+
+
+
+
+
+
+
+
+
+
+
+