public void Checkout(string identifier) { if (identifier == null) { throw new ArgumentNullException(CommonExtensions.GetParameterName <string>(() => identifier)); } using (var repository = new LibGit2Sharp.Repository(_localRepositoryPath)) { var branchName = "origin/" + identifier; var branch = repository.Branches.FirstOrDefault(b => b.FriendlyName == branchName); if (branch != null) { CheckoutedBranch = Commands.Checkout(repository, branch); } } }
public GitRepositoryAccess(Uri localRepositoryPath, CloneOptions cloneOptions = null) { if (cloneOptions == null) { _cloneOptions = new CloneOptions(); _cloneOptions.CredentialsProvider = (_url, _user, _cred) => new UsernamePasswordCredentials { //TODO get this options from default configuration file Username = "******", Password = "******" }; } if (localRepositoryPath == null) { throw new ArgumentNullException(CommonExtensions.GetParameterName <Uri>(() => localRepositoryPath)); } _localRepositoryPath = localRepositoryPath.AbsolutePath; }