本文整理汇总了C#中NGit类的典型用法代码示例。如果您正苦于以下问题:C# NGit类的具体用法?C# NGit怎么用?C# NGit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NGit类属于命名空间,在下文中一共展示了NGit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RepositoryStatus
internal RepositoryStatus(NGit.Repository repository, IEnumerable<string> singleFiles, string rootDir, bool recursive)
{
Repository = repository;
_root_path = rootDir;
_recursive = recursive;
_file_paths = singleFiles;
Update();
}
示例2: RepositoryStatus
internal RepositoryStatus(NGit.Repository repository, string singleFile, string rootDir, bool recursive)
{
Repository = repository;
_root_path = rootDir;
_recursive = recursive;
_file_path = singleFile;
Update();
}
示例3: RebaseOperation
public RebaseOperation (NGit.Repository repo, string upstreamRef, IProgressMonitor monitor)
{
this.monitor = monitor;
this.repo = repo;
this.upstreamRef = upstreamRef;
rw = new RevWalk (repo);
branch = repo.GetBranch ();
starting = true;
}
示例4: CompareCommits
/// <summary>
/// Compares two commits and returns a list of files that have changed
/// </summary>
public static IEnumerable<DiffEntry> CompareCommits (NGit.Repository repo, RevCommit reference, RevCommit compared)
{
var changes = new List<DiffEntry>();
if (reference == null && compared == null)
return changes;
ObjectId refTree = (reference != null ? reference.Tree.Id : ObjectId.ZeroId);
ObjectId comparedTree = (compared != null ? compared.Tree.Id : ObjectId.ZeroId);
return CompareCommits (repo, refTree, comparedTree);
}
示例5: GetCommitChanges
/// <summary>
/// Returns a list of files that have changed in a commit
/// </summary>
public static IEnumerable<Change> GetCommitChanges (NGit.Repository repo, RevCommit commit)
{
var treeIds = new[] { commit.Tree.Id }.Concat (commit.Parents.Select (c => c.Tree.Id)).ToArray ();
var walk = new TreeWalk (repo);
walk.Reset (treeIds);
walk.Recursive = true;
walk.Filter = AndTreeFilter.Create (AndTreeFilter.ANY_DIFF, AndTreeFilter.ALL);
return CalculateCommitDiff (repo, walk, new[] { commit }.Concat (commit.Parents).ToArray ());
}
示例6: Configure
/// <summary>
/// 設定
/// </summary>
/// <param name="hc">ホスト</param>
/// <param name="session">セッション</param>
protected override void Configure(NGit.Transport.OpenSshConfig.Host hc, NSch.Session session)
{
var config = new Properties();
config["StrictHostKeyChecking"] = "no";
config["PreferredAuthentications"] = "publickey";
session.SetConfig(config);
var jsch = this.GetJSch(hc, FS.DETECTED);
jsch.AddIdentity("KeyPair", Encoding.UTF8.GetBytes(PrivateKey), Encoding.UTF8.GetBytes(PublicKey), null);
}
示例7: GetJSch
protected override NSch.JSch GetJSch(OpenSshConfig.Host hc, NGit.Util.FS fs)
{
var jsch = base.GetJSch(hc, fs);
foreach (var certificate in GitCertificates.GetAllCertificates())
{
jsch.AddIdentity(certificate.Path);
}
// Set the known hosts file.
jsch.SetKnownHosts(GetKnownHostsFilename());
return jsch;
}
示例8: GetConflictedFiles
public static List<string> GetConflictedFiles (NGit.Repository repo)
{
List<string> list = new List<string> ();
TreeWalk treeWalk = new TreeWalk (repo);
treeWalk.Reset ();
treeWalk.Recursive = true;
DirCache dc = repo.ReadDirCache ();
treeWalk.AddTree (new DirCacheIterator (dc));
while (treeWalk.Next()) {
DirCacheIterator dirCacheIterator = treeWalk.GetTree<DirCacheIterator>(0);
var ce = dirCacheIterator.GetDirCacheEntry ();
if (ce != null && ce.Stage == 1)
list.Add (ce.PathString);
}
return list;
}
示例9: CompareCommits
/// <summary>
/// Compares two commits and returns a list of files that have changed
/// </summary>
public static IEnumerable<Change> CompareCommits (NGit.Repository repo, RevCommit reference, RevCommit compared)
{
var changes = new List<Change>();
if (reference == null && compared == null)
return changes;
ObjectId refTree = (reference != null ? reference.Tree.Id : ObjectId.ZeroId);
ObjectId comparedTree = (compared != null ? compared.Tree.Id : ObjectId.ZeroId);
var walk = new TreeWalk (repo);
if (reference == null || compared == null)
walk.Reset ((reference ?? compared).Tree.Id);
else
walk.Reset (new AnyObjectId[] {refTree, comparedTree});
walk.Recursive = true;
walk.Filter = AndTreeFilter.Create(TreeFilter.ANY_DIFF, TreeFilter.ALL);
return CalculateCommitDiff (repo, walk, new[] { reference, compared });
}
示例10: BundleFetchConnection
/// <exception cref="NGit.Errors.TransportException"></exception>
internal BundleFetchConnection(NGit.Transport.Transport transportBundle, InputStream
src)
{
transport = transportBundle;
bin = new BufferedInputStream(src);
try
{
switch (ReadSignature())
{
case 2:
{
ReadBundleV2();
break;
}
default:
{
throw new TransportException(transport.uri, JGitText.Get().notABundle);
}
}
}
catch (TransportException err)
{
Close();
throw;
}
catch (IOException err)
{
Close();
throw new TransportException(transport.uri, err.Message, err);
}
catch (RuntimeException err)
{
Close();
throw new TransportException(transport.uri, err.Message, err);
}
}
示例11: IdEqual
/// <summary>Check if the current entry of both iterators has the same id.</summary>
/// <remarks>
/// Check if the current entry of both iterators has the same id.
/// <p>
/// This method is faster than
/// <see cref="EntryObjectId()">EntryObjectId()</see>
/// as it does not
/// require copying the bytes out of the buffers. A direct
/// <see cref="IdBuffer()">IdBuffer()</see>
/// compare operation is performed.
/// </remarks>
/// <param name="otherIterator">the other iterator to test against.</param>
/// <returns>true if both iterators have the same object id; false otherwise.</returns>
public virtual bool IdEqual(NGit.Treewalk.AbstractTreeIterator otherIterator)
{
return ObjectId.Equals(IdBuffer, IdOffset, otherIterator.IdBuffer, otherIterator.
IdOffset);
}
示例12: AlreadyMatch
private static int AlreadyMatch(NGit.Treewalk.AbstractTreeIterator a, NGit.Treewalk.AbstractTreeIterator
b)
{
for (; ; )
{
NGit.Treewalk.AbstractTreeIterator ap = a.parent;
NGit.Treewalk.AbstractTreeIterator bp = b.parent;
if (ap == null || bp == null)
{
return 0;
}
if (ap.matches == bp.matches)
{
return a.pathOffset;
}
a = ap;
b = bp;
}
}
示例13: PathCompare
internal virtual int PathCompare(NGit.Treewalk.AbstractTreeIterator p, int pMode)
{
// Its common when we are a subtree for both parents to match;
// when this happens everything in path[0..cPos] is known to
// be equal and does not require evaluation again.
//
int cPos = AlreadyMatch(this, p);
return PathCompare(p.path, cPos, p.pathLen, pMode, cPos);
}
示例14: AbstractTreeIterator
/// <summary>Create an iterator for a subtree of an existing iterator.</summary>
/// <remarks>
/// Create an iterator for a subtree of an existing iterator.
/// <p>
/// The caller is responsible for setting up the path of the child iterator.
/// </remarks>
/// <param name="p">parent tree iterator.</param>
/// <param name="childPath">
/// path array to be used by the child iterator. This path must
/// contain the path from the top of the walk to the first child
/// and must end with a '/'.
/// </param>
/// <param name="childPathOffset">
/// position within <code>childPath</code> where the child can
/// insert its data. The value at
/// <code>childPath[childPathOffset-1]</code> must be '/'.
/// </param>
protected internal AbstractTreeIterator(NGit.Treewalk.AbstractTreeIterator p, byte
[] childPath, int childPathOffset)
{
parent = p;
path = childPath;
pathOffset = childPathOffset;
}
示例15: InsertCommit
/// <exception cref="System.IO.IOException"></exception>
/// <exception cref="Sharpen.UnsupportedEncodingException"></exception>
private ObjectId InsertCommit(NGit.CommitBuilder builder)
{
ObjectInserter oi = db.NewObjectInserter();
try
{
ObjectId id = oi.Insert(builder);
oi.Flush();
return id;
}
finally
{
oi.Release();
}
}