Skip to content

Commit

Permalink
#225 added DeleteBranch method
Browse files Browse the repository at this point in the history
  • Loading branch information
rubberduck203 committed Mar 8, 2015
1 parent 3dfbee3 commit f6cc9d0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions RetailCoder.VBE/Interop/ISourceControlProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public interface ISourceControlProvider
[DispId(12)]
void CreateBranch(string branch);

[DispId(18)]
void DeleteBranch(string branch);

[DispId(13)]
void Undo(string filePath);

Expand Down
15 changes: 15 additions & 0 deletions RetailCoder.VBE/SourceControl/GitProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,21 @@ public override void Undo(string filePath)
}
}

public override void DeleteBranch(string branch)
{
try
{
if (repo.Branches.Any(b => b.Name == branch && !b.IsRemote))
{
repo.Branches.Remove(branch);
}
}
catch(LibGit2SharpException ex)
{
throw new SourceControlException("Branch deletion failed.", ex);
}
}

private Signature GetSignature()
{
return this.repo.Config.BuildSignature(DateTimeOffset.Now);
Expand Down
18 changes: 12 additions & 6 deletions RetailCoder.VBE/SourceControl/ISourceControlProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public interface ISourceControlProvider
/// Fetches the specified remote for tracking.
/// If argument is not supplied, returns a default remote defined by implementation.
/// </summary>
/// <param name="remoteName"></param>
/// <param name="remoteName">Name of the remote to be fetched.</param>
void Fetch([Optional] string remoteName);

/// <summary>
Expand All @@ -53,28 +53,34 @@ public interface ISourceControlProvider
/// <summary>
/// Stages all modified files and commits to CurrentBranch.
/// </summary>
/// <param name="message"></param>
/// <param name="message">Commit message.</param>
void Commit(string message);

/// <summary>
/// Merges the source branch into the desitnation.
/// </summary>
/// <param name="sourceBranch"></param>
/// <param name="destinationBranch"></param>
/// <param name="sourceBranch">Name of the source branch.</param>
/// <param name="destinationBranch">Name of the target branch.</param>
void Merge(string sourceBranch, string destinationBranch);

/// <summary>
/// Checks out the target branch.
/// </summary>
/// <param name="branch"></param>
/// <param name="branch">Name of the branch to be checked out.</param>
void Checkout(string branch);

/// <summary>
/// Creates and checks out a new branch.
/// </summary>
/// <param name="branch"></param>
/// <param name="branch">Name of the branch to be created.</param>
void CreateBranch(string branch);

/// <summary>
/// Deletes the specified branch from the local repository.
/// </summary>
/// <param name="branch">Name of the branch to be deleted.</param>
void DeleteBranch(string branch);

/// <summary>
/// Undoes uncommitted changes to a particular file.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions RetailCoder.VBE/SourceControl/SourceControlProviderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public SourceControlProviderBase(VBProject project, IRepository repository)
public abstract void AddFile(string filePath);
public abstract void RemoveFile(string filePath);
public abstract void CreateBranch(string branch);
public abstract void DeleteBranch(string branch);
public abstract IRepository Init(string directory, bool bare = false);

public virtual IRepository InitVBAProject(string directory)
Expand Down

0 comments on commit f6cc9d0

Please sign in to comment.