Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
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
23 changes: 12 additions & 11 deletions GitHub.Unity.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=C_0023/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="C#"&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;CSUpdateFileHeader&gt;True&lt;/CSUpdateFileHeader&gt;&lt;CSCodeStyleAttributes ArrangeTypeAccessModifier="True" ArrangeTypeMemberAccessModifier="True" SortModifiers="True" RemoveRedundantParentheses="True" AddMissingParentheses="True" ArrangeBraces="True" ArrangeAttributes="True" ArrangeArgumentsStyle="True" /&gt;&lt;CSEnforceVarKeywordUsageSettings&gt;True&lt;/CSEnforceVarKeywordUsageSettings&gt;&lt;CSArrangeQualifiers&gt;True&lt;/CSArrangeQualifiers&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;False&lt;/EmbraceInRegion&gt;&lt;RegionName&gt;&lt;/RegionName&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Relayout/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Relayout"&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;/Profile&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/RecentlyUsedProfile/@EntryValue">C#</s:String>
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">C#</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOR/@EntryValue">Required</s:String>
Expand Down Expand Up @@ -262,17 +263,6 @@
&lt;ImplementsInterface Immediate="True" /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Other Static Methods" Priority="49"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Method" /&gt;&#xD;
&lt;Static /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Access /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Other Instance Methods" Priority="39"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
Expand Down Expand Up @@ -300,6 +290,17 @@
&lt;ImplementsInterface Immediate="True" /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Other Static Methods" Priority="49"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;And&gt;&#xD;
&lt;Kind Is="Method" /&gt;&#xD;
&lt;Static /&gt;&#xD;
&lt;/And&gt;&#xD;
&lt;/Entry.Match&gt;&#xD;
&lt;Entry.SortBy&gt;&#xD;
&lt;Access /&gt;&#xD;
&lt;/Entry.SortBy&gt;&#xD;
&lt;/Entry&gt;&#xD;
&lt;Entry DisplayName="Dispose Implementation" Priority="100"&gt;&#xD;
&lt;Entry.Match&gt;&#xD;
&lt;Or&gt;&#xD;
Expand Down
70 changes: 37 additions & 33 deletions src/GitHub.Api/Git/RepositoryManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -11,21 +10,13 @@ interface IRepositoryManager : IDisposable
{
event Action OnActiveBranchChanged;
event Action OnActiveRemoteChanged;
event Action OnRemoteBranchListChanged;
event Action<bool> OnIsBusyChanged;
event Action OnLocalBranchListChanged;
event Action<GitStatus> OnStatusUpdated;
event Action OnHeadChanged;
event Action<bool> OnIsBusyChanged;
event Action OnRemoteOrTrackingChanged;
event Action<GitStatus> OnStatusUpdated;
event Action<IEnumerable<GitLock>> OnLocksUpdated;
Dictionary<string, ConfigBranch> LocalBranches { get; }
Dictionary<string, Dictionary<string, ConfigBranch>> RemoteBranches { get; }
IRepository Repository { get; }
IGitConfig Config { get; }
ConfigBranch? ActiveBranch { get; }
ConfigRemote? ActiveRemote { get; }
IGitClient GitClient { get; }
bool IsBusy { get; }
event Action OnRemoteBranchListChanged;
event Action OnRemoteOrTrackingChanged;
Task Initialize();
void Start();
void Stop();
Expand All @@ -44,6 +35,14 @@ interface IRepositoryManager : IDisposable
ITask ListLocks(bool local);
ITask LockFile(string file);
ITask UnlockFile(string file, bool force);
Dictionary<string, ConfigBranch> LocalBranches { get; }
Dictionary<string, Dictionary<string, ConfigBranch>> RemoteBranches { get; }
IRepository Repository { get; }
IGitConfig Config { get; }
ConfigBranch? ActiveBranch { get; }
ConfigRemote? ActiveRemote { get; }
IGitClient GitClient { get; }
bool IsBusy { get; }
}

interface IRepositoryPathConfiguration
Expand Down Expand Up @@ -91,17 +90,17 @@ public RepositoryPathConfiguration(NPath repositoryPath)

class RepositoryManagerFactory
{
public RepositoryManager CreateRepositoryManager(IPlatform platform, ITaskManager taskManager, IUsageTracker usageTracker,
IGitClient gitClient, NPath repositoryRoot)
public RepositoryManager CreateRepositoryManager(IPlatform platform, ITaskManager taskManager,
IUsageTracker usageTracker, IGitClient gitClient, NPath repositoryRoot)
{
var repositoryPathConfiguration = new RepositoryPathConfiguration(repositoryRoot);
string filePath = repositoryPathConfiguration.DotGitConfig;
var gitConfig = new GitConfig(filePath);

var repositoryWatcher = new RepositoryWatcher(platform, repositoryPathConfiguration, taskManager.Token);

return new RepositoryManager(platform, taskManager, usageTracker, gitConfig, repositoryWatcher,
gitClient, repositoryPathConfiguration, taskManager.Token);
return new RepositoryManager(platform, taskManager, usageTracker, gitConfig, repositoryWatcher, gitClient,
repositoryPathConfiguration, taskManager.Token);
}
}

Expand All @@ -110,34 +109,34 @@ class RepositoryManager : IRepositoryManager
private readonly Dictionary<string, ConfigBranch> branches = new Dictionary<string, ConfigBranch>();
private readonly CancellationToken cancellationToken;
private readonly IGitConfig config;
private readonly IGitClient gitClient;
private readonly IPlatform platform;
private readonly IRepositoryPathConfiguration repositoryPaths;
private readonly ITaskManager taskManager;
private readonly IUsageTracker usageTracker;
private IRepository repository;
private readonly IRepositoryPathConfiguration repositoryPaths;
private readonly IGitClient gitClient;
private readonly IRepositoryWatcher watcher;

private ConfigBranch? activeBranch;
private ConfigRemote? activeRemote;
private string head;
private bool isBusy;
private IEnumerable<GitLock> locks;
private Dictionary<string, Dictionary<string, ConfigBranch>> remoteBranches = new Dictionary<string, Dictionary<string, ConfigBranch>>();
private Dictionary<string, ConfigRemote> remotes;
private IEnumerable<GitLock> locks;
private IRepository repository;

public event Action OnActiveBranchChanged;
public event Action OnActiveRemoteChanged;
public event Action OnRemoteBranchListChanged;
public event Action OnLocalBranchListChanged;
public event Action<GitStatus> OnStatusUpdated;
public event Action OnHeadChanged;
public event Action<bool> OnIsBusyChanged;
public event Action OnRemoteOrTrackingChanged;
public event Action OnLocalBranchListChanged;
public event Action<IEnumerable<GitLock>> OnLocksUpdated;
public event Action OnRemoteBranchListChanged;
public event Action OnRemoteOrTrackingChanged;
public event Action<GitStatus> OnStatusUpdated;

public RepositoryManager(IPlatform platform, ITaskManager taskManager, IUsageTracker usageTracker, IGitConfig gitConfig,
IRepositoryWatcher repositoryWatcher, IGitClient gitClient,
public RepositoryManager(IPlatform platform, ITaskManager taskManager, IUsageTracker usageTracker,
IGitConfig gitConfig, IRepositoryWatcher repositoryWatcher, IGitClient gitClient,
IRepositoryPathConfiguration repositoryPaths, CancellationToken cancellationToken)
{
this.repositoryPaths = repositoryPaths;
Expand All @@ -163,9 +162,11 @@ public RepositoryManager(IPlatform platform, ITaskManager taskManager, IUsageTra

var remote = config.GetRemote("origin");
if (!remote.HasValue)
{
remote = config.GetRemotes()
.Where(x => HostAddress.Create(new UriString(x.Url).ToRepositoryUri()).IsGitHubDotCom())
.FirstOrDefault();
.Where(x => HostAddress.Create(new UriString(x.Url).ToRepositoryUri()).IsGitHubDotCom())
.FirstOrDefault();
}
UriString cloneUrl = "";
if (remote.Value.Url != null)
{
Expand Down Expand Up @@ -398,8 +399,7 @@ private void Watcher_OnHeadChanged(string contents)
}

private void Watcher_OnIndexChanged()
{
}
{ }

private void Watcher_OnLocalBranchCreated(string name)
{
Expand Down Expand Up @@ -436,6 +436,7 @@ private async Task<IRepository> InitializeRepository()
{
throw new InvalidOperationException("No user configured");
}

user.Email = res;
repository.User = user;
return repository;
Expand Down Expand Up @@ -599,6 +600,7 @@ private void RemoveRemoteBranch(string remote, string name)
}

private bool disposed;

private void Dispose(bool disposing)
{
if (disposed) return;
Expand Down Expand Up @@ -628,7 +630,8 @@ public ConfigBranch? ActiveBranch
get { return activeBranch; }
private set
{
if (activeBranch.HasValue != value.HasValue || (activeBranch.HasValue && !activeBranch.Value.Equals(value.Value)))
if (activeBranch.HasValue != value.HasValue ||
activeBranch.HasValue && !activeBranch.Value.Equals(value.Value))
{
activeBranch = value;
Logger.Trace("OnActiveBranchChanged: {0}", value?.ToString() ?? "NULL");
Expand All @@ -642,7 +645,8 @@ public ConfigRemote? ActiveRemote
get { return activeRemote; }
private set
{
if (activeRemote.HasValue != value.HasValue || (activeRemote.HasValue && !activeRemote.Value.Equals(value.Value)))
if (activeRemote.HasValue != value.HasValue ||
activeRemote.HasValue && !activeRemote.Value.Equals(value.Value))
{
activeRemote = value;
Logger.Trace("OnActiveRemoteChanged: {0}", value?.ToString() ?? "NULL");
Expand Down
Loading