Created
September 4, 2013 17:06
-
-
Save mm201/6439858 to your computer and use it in GitHub Desktop.
Testcase for push issue with libgit2sharp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using LibGit2Sharp; | |
namespace PushTestcase | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
String wd = Directory.GetCurrentDirectory(); | |
String path = wd + "\\test-repo"; | |
Directory.CreateDirectory(path); | |
Repository.Init(path); | |
Console.WriteLine("Initialized test-repo"); | |
StreamWriter sw = File.CreateText(path + "\\test.txt"); | |
sw.Write("This is a test document which will be committed."); | |
Console.WriteLine("Wrote file."); | |
Repository repo = new Repository(path); | |
repo.Index.Stage("test.txt"); | |
Console.WriteLine("Staged file."); | |
repo.Commit("Test commit."); | |
Console.WriteLine("Committed."); | |
repo.Dispose(); | |
repo = null; | |
String clone_path = wd + "\\clone-repo"; | |
Directory.CreateDirectory(clone_path); | |
Repository.Clone(path, clone_path); | |
Console.WriteLine("Cloned repository."); | |
repo = new Repository(path); | |
repo.Branches.Add("otherBranch", repo.Head.Tip); | |
Console.WriteLine("Created secondary branch."); | |
repo.Branches["otherBranch"].Checkout(); // checkout a different branch so we can push master | |
Console.WriteLine("Checked out secondary branch."); | |
repo.Dispose(); | |
repo = null; | |
Repository clone = new Repository(clone_path); | |
clone.Network.Push(clone.Head); | |
Console.WriteLine("Pushed."); | |
clone.Dispose(); | |
clone = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment