Skip to content

Commit 5ca51e1

Browse files
committed
closes #220; extracted IRepository interface
1 parent 6d8d23b commit 5ca51e1

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

RetailCoder.VBE/SourceControl/GitProvider.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class GitProvider : SourceControlProviderBase
1717
private Credentials creds;
1818
private LibGit2Sharp.Handlers.CredentialsHandler credHandler;
1919

20-
public GitProvider(VBProject project, Repository repository)
20+
public GitProvider(VBProject project, IRepository repository)
2121
: base(project, repository) { }
2222

23-
public GitProvider(VBProject project, Repository repository, string userName, string passWord)
23+
public GitProvider(VBProject project, IRepository repository, string userName, string passWord)
2424
: this(project, repository)
2525
{
2626
repo = new LibGit2Sharp.Repository(CurrentRepository.LocalLocation);
@@ -57,7 +57,7 @@ public override IEnumerable<string> Branches
5757
}
5858
}
5959

60-
public override Repository Clone(string remotePathOrUrl, string workingDirectory)
60+
public override IRepository Clone(string remotePathOrUrl, string workingDirectory)
6161
{
6262
try
6363
{
@@ -70,7 +70,7 @@ public override Repository Clone(string remotePathOrUrl, string workingDirectory
7070
}
7171
}
7272

73-
public override Repository Init(string directory, bool bare = false)
73+
public override IRepository Init(string directory, bool bare = false)
7474
{
7575
try
7676
{
@@ -96,7 +96,7 @@ public override Repository Init(string directory, bool bare = false)
9696
}
9797
}
9898

99-
public override Repository InitVBAProject(string directory)
99+
public override IRepository InitVBAProject(string directory)
100100
{
101101
var repository = base.InitVBAProject(directory);
102102
Init(directory);

RetailCoder.VBE/SourceControl/ISourceControlProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ namespace Rubberduck.SourceControl
99
{
1010
public interface ISourceControlProvider
1111
{
12-
Repository CurrentRepository { get; }
12+
IRepository CurrentRepository { get; }
1313
string CurrentBranch { get; }
1414
IEnumerable<string> Branches { get; }
1515

1616
/// <summary>Clone a remote repository.</summary>
1717
/// <param name="remotePathOrUrl">Either a Url "https://github.com/retailcoder/Rubberduck.git" or a UNC path. "//server/share/path/to/repo.git"</param>
1818
/// <param name="workingDirectory">Directory the repository will be cloned to.</param>
1919
/// <returns>Newly cloned repository.</returns>
20-
Repository Clone(string remotePathOrUrl, string workingDirectory);
20+
IRepository Clone(string remotePathOrUrl, string workingDirectory);
2121

2222
/// <summary>
2323
/// Creates a new repository in/from the given directory.
2424
/// </summary>
2525
/// <param name="directory">The directory where the new repository will be created.</param>
2626
/// <returns>Newly created repository.</returns>
27-
Repository Init(string directory, bool bare = false);
27+
IRepository Init(string directory, bool bare = false);
2828

2929
/// <summary>
3030
/// Creates a new repository and sets the CurrentRepository property from the VBProject passed to the ISourceControlProvider upon creation.
3131
/// </summary>
3232
/// <param name="directory"></param>
3333
/// <returns>Newly created Repository.</returns>
34-
Repository InitVBAProject(string directory);
34+
IRepository InitVBAProject(string directory);
3535

3636
//todo: document
3737
void Push();

RetailCoder.VBE/SourceControl/Repository.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@
66

77
namespace Rubberduck.SourceControl
88
{
9-
public class Repository
9+
public interface IRepository
10+
{
11+
string LocalLocation { get; }
12+
string Name { get; }
13+
string RemoteLocation { get; }
14+
}
15+
16+
public class Repository : Rubberduck.SourceControl.IRepository
1017
{
1118
public string Name { get; private set; }
1219
public string LocalLocation { get; private set; }

RetailCoder.VBE/SourceControl/SourceControlProviderBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,24 @@ public SourceControlProviderBase(VBProject project)
1717
this.project = project;
1818
}
1919

20-
public SourceControlProviderBase(VBProject project, Repository repository)
20+
public SourceControlProviderBase(VBProject project, IRepository repository)
2121
:this(project)
2222
{
2323
this.CurrentRepository = repository;
2424
}
2525

26-
public Repository CurrentRepository { get; private set; }
26+
public IRepository CurrentRepository { get; private set; }
2727
public abstract string CurrentBranch { get; }
2828
public abstract IEnumerable<string> Branches { get; }
29-
public abstract Repository Clone(string remotePathOrUrl, string workingDirectory);
29+
public abstract IRepository Clone(string remotePathOrUrl, string workingDirectory);
3030
public abstract void Push();
3131
public abstract void Fetch(string remoteName);
3232
public abstract void AddFile(string filePath);
3333
public abstract void RemoveFile(string filePath);
3434
public abstract void CreateBranch(string branch);
35-
public abstract Repository Init(string directory, bool bare = false);
35+
public abstract IRepository Init(string directory, bool bare = false);
3636

37-
public virtual Repository InitVBAProject(string directory)
37+
public virtual IRepository InitVBAProject(string directory)
3838
{
3939
var projectName = GetProjectNameFromDirectory(directory);
4040
if (projectName != string.Empty && projectName != this.project.Name)

0 commit comments

Comments
 (0)