本文整理汇总了C#中Repository.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Resolve方法的具体用法?C# Repository.Resolve怎么用?C# Repository.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.Resolve方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoteRefUpdate
public RemoteRefUpdate(Repository localDb, string srcRef, string remoteName, bool forceUpdate, string localName, ObjectId expectedOldObjectId)
{
if (remoteName == null)
throw new ArgumentException("Remote name can't be null.");
SourceRef = srcRef;
NewObjectId = (srcRef == null ? ObjectId.ZeroId : localDb.Resolve(srcRef));
if (NewObjectId == null)
{
throw new IOException("Source ref " + srcRef + " doesn't resolve to any object.");
}
RemoteName = remoteName;
ForceUpdate = forceUpdate;
if (localName != null && localDb != null)
{
TrackingRefUpdate = new TrackingRefUpdate(localDb, localName, remoteName, true, NewObjectId, "push");
}
else
{
TrackingRefUpdate = null;
}
this.localDb = localDb;
ExpectedOldObjectId = expectedOldObjectId;
Status = UpdateStatus.NOT_ATTEMPTED;
}
示例2: SetUp
public override void SetUp()
{
base.SetUp();
src = CreateBareRepository();
dst = CreateBareRepository();
// Fill dst with a some common history.
//
TestRepository d = new TestRepository<Repository>(dst);
a = d.Blob("a");
A = d.Commit(d.Tree(d.File("a", a)));
B = d.Commit().Parent(A).Create();
d.Update(R_MASTER, B);
// Clone from dst into src
//
NGit.Transport.Transport t = NGit.Transport.Transport.Open(src, UriOf(dst));
try
{
t.Fetch(PM, Collections.Singleton(new RefSpec("+refs/*:refs/*")));
NUnit.Framework.Assert.AreEqual(B, src.Resolve(R_MASTER));
}
finally
{
t.Close();
}
// Now put private stuff into dst.
//
b = d.Blob("b");
P = d.Commit(d.Tree(d.File("b", b)), A);
d.Update(R_PRIVATE, P);
}
示例3: Refresh
public void Refresh()
{
this.index = null;
this.commitTree = null;
this.cache.Clear();
this.changedFiles = null;
this.repositoryGraph = null;
this.dirCache = null;
this.head = null;
this.ignoreRules = null;
this.remotes = null;
this.configs = null;
if (!string.IsNullOrEmpty(initFolder))
{
try
{
this.repository = Open(new DirectoryInfo(initFolder));
if (this.repository != null)
{
dirCache = repository.ReadDirCache();
head = repository.Resolve(Constants.HEAD);
if (head == null)
{
this.commitTree = new Tree(repository);
}
else
{
var treeId = ObjectId.FromString(repository.Open(head).GetBytes(), 5);
this.commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
}
if (repository.IsBare)
throw new NoWorkTreeException();
this.index = new GitIndex(repository);
this.index.Read();
this.index.RereadIfNecessary();
try
{
//load local .gitignore file
var ignoreFile = Path.Combine(this.initFolder,
Constants.GITIGNORE_FILENAME);
if (File.Exists(ignoreFile))
{
ignoreRules = File.ReadAllLines(ignoreFile)
.Where(line => !line.StartsWith("#") && line.Trim().Length > 0)
.Select(line => new IgnoreRule(line)).ToList();
}
}
catch (Exception ex)
{
Log.WriteLine("ReadIgnoreFile: {0}\r\n{1}", this.initFolder, ex.ToString());
}
}
}
catch (Exception ex)
{
this.repository = null;
Log.WriteLine("Refresh: {0}\r\n{1}", this.initFolder, ex.ToString());
}
}
}
示例4: IndexDiff
/// <summary>Construct an IndexDiff</summary>
/// <param name="repository"></param>
/// <param name="revstr">
/// symbolic name e.g. HEAD
/// An EmptyTreeIterator is used if <code>revstr</code> cannot be resolved.
/// </param>
/// <param name="workingTreeIterator">iterator for working directory</param>
/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
public IndexDiff(Repository repository, string revstr, WorkingTreeIterator workingTreeIterator
)
{
this.repository = repository;
ObjectId objectId = repository.Resolve(revstr);
if (objectId != null)
{
tree = new RevWalk(repository).ParseTree(objectId);
}
else
{
tree = null;
}
this.initialWorkingTreeIterator = workingTreeIterator;
}
示例5: Refresh
public void Refresh()
{
this.cache.Clear();
this.changedFiles = null;
this.repositoryGraph = null;
this.head = null;
this.remotes = null;
this.configs = null;
if (!string.IsNullOrEmpty(initFolder))
{
try
{
this.repository = Open(new DirectoryInfo(initFolder));
if (this.repository != null)
{
head = repository.Resolve(Constants.HEAD);
if (repository.IsBare)
throw new NoWorkTreeException();
}
}
catch (Exception ex)
{
this.repository = null;
Log.WriteLine("Refresh: {0}\r\n{1}", this.initFolder, ex.ToString());
}
}
}
示例6: RemoteRefUpdate
/// <summary>Construct remote ref update request by providing an update specification.
/// </summary>
/// <remarks>
/// Construct remote ref update request by providing an update specification.
/// Object is created with default
/// <see cref="Status.NOT_ATTEMPTED">Status.NOT_ATTEMPTED</see>
/// status and no
/// message.
/// </remarks>
/// <param name="localDb">local repository to push from.</param>
/// <param name="srcRef">
/// source revision - any string resolvable by
/// <see cref="NGit.Repository.Resolve(string)">NGit.Repository.Resolve(string)</see>
/// . This resolves to the new
/// object that the caller want remote ref to be after update. Use
/// null or
/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
/// string for delete request.
/// </param>
/// <param name="remoteName">
/// full name of a remote ref to update, e.g. "refs/heads/master"
/// (no wildcard, no short name).
/// </param>
/// <param name="forceUpdate">
/// true when caller want remote ref to be updated regardless
/// whether it is fast-forward update (old object is ancestor of
/// new object).
/// </param>
/// <param name="localName">
/// optional full name of a local stored tracking branch, to
/// update after push, e.g. "refs/remotes/zawir/dirty" (no
/// wildcard, no short name); null if no local tracking branch
/// should be updated.
/// </param>
/// <param name="expectedOldObjectId">
/// optional object id that caller is expecting, requiring to be
/// advertised by remote side before update; update will take
/// place ONLY if remote side advertise exactly this expected id;
/// null if caller doesn't care what object id remote side
/// advertise. Use
/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
/// when expecting no
/// remote ref with this name.
/// </param>
/// <exception cref="System.IO.IOException">
/// when I/O error occurred during creating
/// <see cref="TrackingRefUpdate">TrackingRefUpdate</see>
/// for local tracking branch or srcRef
/// can't be resolved to any object.
/// </exception>
/// <exception cref="System.ArgumentException">if some required parameter was null</exception>
public RemoteRefUpdate(Repository localDb, string srcRef, string remoteName, bool
forceUpdate, string localName, ObjectId expectedOldObjectId)
{
if (remoteName == null)
{
throw new ArgumentException(JGitText.Get().remoteNameCantBeNull);
}
this.srcRef = srcRef;
this.newObjectId = (srcRef == null ? ObjectId.ZeroId : localDb.Resolve(srcRef));
if (newObjectId == null)
{
throw new IOException(MessageFormat.Format(JGitText.Get().sourceRefDoesntResolveToAnyObject
, srcRef));
}
this.remoteName = remoteName;
this.forceUpdate = forceUpdate;
if (localName != null && localDb != null)
{
trackingRefUpdate = new TrackingRefUpdate(localDb, localName, remoteName, true, newObjectId
, "push");
}
else
{
trackingRefUpdate = null;
}
this.localDb = localDb;
this.expectedOldObjectId = expectedOldObjectId;
this.status = RemoteRefUpdate.Status.NOT_ATTEMPTED;
}
示例7: testRenameBranchAlsoInPack
public void testRenameBranchAlsoInPack()
{
ObjectId rb = db.Resolve("refs/heads/b");
ObjectId rb2 = db.Resolve("refs/heads/b~1");
Assert.AreEqual(Ref.Storage.Packed, db.getRef("refs/heads/b").StorageFormat);
RefUpdate updateRef = db.UpdateRef("refs/heads/b");
updateRef.NewObjectId = rb2;
updateRef.IsForceUpdate = true;
RefUpdate.RefUpdateResult update = updateRef.Update();
Assert.AreEqual(RefUpdate.RefUpdateResult.Forced, update, "internal check new ref is loose");
Assert.AreEqual(Ref.Storage.LoosePacked, db.getRef("refs/heads/b")
.StorageFormat);
RefLogWriter.WriteReflog(db, rb, rb, "Just a message", "refs/heads/b");
Assert.IsTrue(new FileInfo(Path.Combine(db.Directory.FullName, "logs/refs/heads/b")).Exists, "no log on old branch");
RefRename renameRef = db.RenameRef("refs/heads/b",
"refs/heads/new/name");
RefUpdate.RefUpdateResult result = renameRef.Rename();
Assert.AreEqual(RefUpdate.RefUpdateResult.Renamed, result);
Assert.AreEqual(rb2, db.Resolve("refs/heads/new/name"));
Assert.IsNull(db.Resolve("refs/heads/b"));
Assert.AreEqual("Branch: renamed b to new/name", db.ReflogReader(
"new/name").getLastEntry().getComment());
Assert.IsFalse(new FileInfo(Path.Combine(db.Directory.FullName, "logs/refs/heads/b")).Exists);
// Create new Repository instance, to reread caches and make sure our
// assumptions are persistent.
Repository ndb = new Repository(db.Directory);
Assert.AreEqual(rb2, ndb.Resolve("refs/heads/new/name"));
Assert.IsNull(ndb.Resolve("refs/heads/b"));
}
示例8: GetTreeIdFromCommitId
private ObjectId GetTreeIdFromCommitId(Repository repository, string commitId)
{
var id = repository.Resolve(commitId);
if (id == null) return null;
RevWalk walk = new RevWalk(repository);
RevCommit commit = walk.ParseCommit(id);
walk.Dispose();
return commit == null || commit.Tree == null ? null :
commit.Tree.Id;
}
示例9: RemoteRefUpdate
/// <summary>Construct remote ref update request by providing an update specification.
/// </summary>
/// <remarks>
/// Construct remote ref update request by providing an update specification.
/// Object is created with default
/// <see cref="Status.NOT_ATTEMPTED">Status.NOT_ATTEMPTED</see>
/// status and no
/// message.
/// </remarks>
/// <param name="localDb">local repository to push from.</param>
/// <param name="srcRef">
/// source revision - any string resolvable by
/// <see cref="NGit.Repository.Resolve(string)">NGit.Repository.Resolve(string)</see>
/// . This resolves to the new
/// object that the caller want remote ref to be after update. Use
/// null or
/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
/// string for delete request.
/// </param>
/// <param name="remoteName">
/// full name of a remote ref to update, e.g. "refs/heads/master"
/// (no wildcard, no short name).
/// </param>
/// <param name="forceUpdate">
/// true when caller want remote ref to be updated regardless
/// whether it is fast-forward update (old object is ancestor of
/// new object).
/// </param>
/// <param name="localName">
/// optional full name of a local stored tracking branch, to
/// update after push, e.g. "refs/remotes/zawir/dirty" (no
/// wildcard, no short name); null if no local tracking branch
/// should be updated.
/// </param>
/// <param name="expectedOldObjectId">
/// optional object id that caller is expecting, requiring to be
/// advertised by remote side before update; update will take
/// place ONLY if remote side advertise exactly this expected id;
/// null if caller doesn't care what object id remote side
/// advertise. Use
/// <see cref="NGit.ObjectId.ZeroId()">NGit.ObjectId.ZeroId()</see>
/// when expecting no
/// remote ref with this name.
/// </param>
/// <exception cref="System.IO.IOException">
/// when I/O error occurred during creating
/// <see cref="TrackingRefUpdate">TrackingRefUpdate</see>
/// for local tracking branch or srcRef
/// can't be resolved to any object.
/// </exception>
/// <exception cref="System.ArgumentException">if some required parameter was null</exception>
public RemoteRefUpdate(Repository localDb, string srcRef, string remoteName, bool
forceUpdate, string localName, ObjectId expectedOldObjectId)
: this(localDb, srcRef
, srcRef != null ? localDb.Resolve(srcRef) : ObjectId.ZeroId, remoteName, forceUpdate
, localName, expectedOldObjectId)
{
}
示例10: Refresh
public void Refresh()
{
this.cache.Clear();
this.changedFiles = null;
this.repositoryGraph = null;
if (!string.IsNullOrEmpty(initFolder))
{
try
{
this.repository = Git.Open(initFolder).GetRepository();
if (this.repository != null)
{
var id = repository.Resolve(Constants.HEAD);
//var commit = repository.MapCommit(id);
//this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
if (id == null)
{
this.commitTree = new Tree(repository);
}
else
{
var treeId = ObjectId.FromString(repository.Open(id).GetBytes(), 5);
this.commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
}
this.index = repository.GetIndex();
this.index.RereadIfNecessary();
ignoreRules = File.ReadAllLines(Path.Combine(this.initFolder, Constants.GITIGNORE_FILENAME))
.Where(line => !line.StartsWith("#") && line.Trim().Length > 0)
.Select(line => new IgnoreRule(line)).ToList();
}
}
catch (Exception ex)
{
}
}
}
示例11: Refresh
public void Refresh()
{
this.cache.Clear();
this.changedFiles = null;
if (!string.IsNullOrEmpty(initFolder))
{
try
{
this.repository = Git.Open(initFolder).GetRepository();
if (this.repository != null)
{
var id = repository.Resolve(Constants.HEAD);
//var commit = repository.MapCommit(id);
//this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
if (id == null)
{
this.commitTree = new Tree(repository);
}
else
{
var treeId = ObjectId.FromString(repository.Open(id).GetBytes(), 5);
this.commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
}
this.index = repository.GetIndex();
this.index.RereadIfNecessary();
}
}
catch (Exception ex)
{
}
}
}