Created
September 19, 2014 20:25
-
-
Save phrohdoh/d317b6e0c519360b15f8 to your computer and use it in GitHub Desktop.
libgit2sharp troubles
This file contains 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 System.Collections.Generic; | |
using System.Linq; | |
using LibGit2Sharp; | |
namespace GitSharp | |
{ | |
class MainClass | |
{ | |
public static void Main(string[] args) | |
{ | |
if (args.Length < 2) | |
{ | |
Console.WriteLine("Usage:"); | |
Console.WriteLine("\targ1: output dir\n\targ2: repo http url"); | |
return; | |
} | |
var outputDir = Path.Combine(Environment.CurrentDirectory, args[0]); | |
if (Directory.Exists(outputDir)) | |
Directory.Delete(outputDir); | |
else | |
Directory.CreateDirectory(outputDir); | |
Console.WriteLine("Output: {0}", outputDir); | |
var repoSource = args[1]; | |
Console.WriteLine("Repo: {0}", repoSource); | |
var path = Repository.Clone(repoSource, outputDir); | |
Console.WriteLine("Valid repo? {0}", Repository.IsValid(outputDir)); | |
using (var repo = new Repository(path)) | |
{ | |
var origin = repo.Network.Remotes["origin"]; | |
repo.Network.Fetch(origin); | |
repo.Reset(ResetMode.Hard, "origin/bleed"); | |
var master = repo.Branches["master"]; // Type is `Branch` from LibGit2Sharp | |
var bleed = repo.Branches["bleed"]; | |
// Here is where the System.ArgumentNullException (not NRE) is thrown | |
// This call is using Repository.Checkout(Branch branch, Signature signature = null) so it has a default for the second param | |
repo.Checkout(master); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment