本文整理汇总了C#中Ref.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# Ref.GetName方法的具体用法?C# Ref.GetName怎么用?C# Ref.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ref
的用法示例。
在下文中一共展示了Ref.GetName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
/// <summary>Construct the merge commit message.</summary>
/// <remarks>Construct the merge commit message.</remarks>
/// <param name="refsToMerge">the refs which will be merged</param>
/// <param name="target">the branch ref which will be merged into</param>
/// <returns>merge commit message</returns>
public virtual string Format(IList<Ref> refsToMerge, Ref target)
{
StringBuilder sb = new StringBuilder();
sb.Append("Merge ");
IList<string> branches = new AList<string>();
IList<string> remoteBranches = new AList<string>();
IList<string> tags = new AList<string>();
IList<string> commits = new AList<string>();
IList<string> others = new AList<string>();
foreach (Ref @ref in refsToMerge)
{
if (@ref.GetName().StartsWith(Constants.R_HEADS))
{
branches.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().StartsWith(Constants.R_REMOTES))
{
remoteBranches.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().StartsWith(Constants.R_TAGS))
{
tags.AddItem("'" + Repository.ShortenRefName(@ref.GetName()) + "'");
}
else
{
if (@ref.GetName().Equals(@ref.GetObjectId().GetName()))
{
commits.AddItem("'" + @ref.GetName() + "'");
}
else
{
others.AddItem(@ref.GetName());
}
}
}
}
}
IList<string> listings = new AList<string>();
if (!branches.IsEmpty())
{
listings.AddItem(JoinNames(branches, "branch", "branches"));
}
if (!remoteBranches.IsEmpty())
{
listings.AddItem(JoinNames(remoteBranches, "remote branch", "remote branches"));
}
if (!tags.IsEmpty())
{
listings.AddItem(JoinNames(tags, "tag", "tags"));
}
if (!commits.IsEmpty())
{
listings.AddItem(JoinNames(commits, "commit", "commits"));
}
if (!others.IsEmpty())
{
listings.AddItem(StringUtils.Join(others, ", ", " and "));
}
sb.Append(StringUtils.Join(listings, ", "));
string targetName = target.GetLeaf().GetName();
if (!targetName.Equals(Constants.R_HEADS + Constants.MASTER))
{
string targetShortName = Repository.ShortenRefName(target.GetName());
sb.Append(" into " + targetShortName);
}
return sb.ToString();
}
示例2: Include
/// <summary>Include a single ref (a name/object pair) in the bundle.</summary>
/// <remarks>
/// Include a single ref (a name/object pair) in the bundle.
/// <p>
/// This is a utility function for:
/// <code>include(r.getName(), r.getObjectId())</code>.
/// </remarks>
/// <param name="r">the ref to include.</param>
public virtual void Include(Ref r)
{
Include(r.GetName(), r.GetObjectId());
if (r.GetPeeledObjectId() != null)
{
tagTargets.AddItem(r.GetPeeledObjectId());
}
else
{
if (r.GetObjectId() != null && r.GetName().StartsWith(Constants.R_HEADS))
{
tagTargets.AddItem(r.GetObjectId());
}
}
}
示例3: Want
/// <exception cref="NGit.Errors.TransportException"></exception>
private void Want(Ref src, RefSpec spec)
{
ObjectId newId = src.GetObjectId();
if (spec.GetDestination() != null)
{
try
{
TrackingRefUpdate tru = CreateUpdate(spec, newId);
if (newId.Equals(tru.GetOldObjectId()))
{
return;
}
localUpdates.AddItem(tru);
}
catch (IOException err)
{
// Bad symbolic ref? That is the most likely cause.
//
throw new TransportException(MessageFormat.Format(JGitText.Get().cannotResolveLocalTrackingRefForUpdating
, spec.GetDestination()), err);
}
}
askFor.Put(newId, src);
FetchHeadRecord fhr = new FetchHeadRecord();
fhr.newValue = newId;
fhr.notForMerge = spec.GetDestination() != null;
fhr.sourceName = src.GetName();
fhr.sourceURI = transport.GetURI();
fetchHeadUpdates.AddItem(fhr);
}
示例4: WantTag
/// <exception cref="NGit.Errors.TransportException"></exception>
private void WantTag(Ref r)
{
Want(r, new RefSpec().SetSource(r.GetName()).SetDestination(r.GetName()));
}
示例5: IsTag
private static bool IsTag(Ref r)
{
return IsTag(r.GetName());
}
示例6: DeleteTrackingRef
/// <exception cref="NGit.Errors.TransportException"></exception>
private void DeleteTrackingRef(FetchResult result, Repository db, RevWalk walk, RefSpec
spec, Ref localRef)
{
string name = localRef.GetName();
try
{
TrackingRefUpdate u = new TrackingRefUpdate(db, name, spec.GetSource(), true, ObjectId
.ZeroId, "deleted");
result.Add(u);
if (transport.IsDryRun())
{
return;
}
u.Delete(walk);
switch (u.GetResult())
{
case RefUpdate.Result.NEW:
case RefUpdate.Result.NO_CHANGE:
case RefUpdate.Result.FAST_FORWARD:
case RefUpdate.Result.FORCED:
{
break;
}
default:
{
throw new TransportException(transport.GetURI(), MessageFormat.Format(JGitText.Get
().cannotDeleteStaleTrackingRef2, name, u.GetResult().ToString()));
}
}
}
catch (IOException e)
{
throw new TransportException(transport.GetURI(), MessageFormat.Format(JGitText.Get
().cannotDeleteStaleTrackingRef, name), e);
}
}
示例7: ExpandFromSource
/// <summary>Expand this specification to exactly match a ref.</summary>
/// <remarks>
/// Expand this specification to exactly match a ref.
/// <p>
/// Callers must first verify the passed ref matches this specification,
/// otherwise expansion results may be unpredictable.
/// </remarks>
/// <param name="r">
/// a ref that matched our source specification. Could be a
/// wildcard also.
/// </param>
/// <returns>
/// a new specification expanded from provided ref name. Result
/// specification is wildcard if and only if provided ref name is
/// wildcard.
/// </returns>
public virtual NGit.Transport.RefSpec ExpandFromSource(Ref r)
{
return ExpandFromSource(r.GetName());
}
示例8: ExpandFromDestination
/// <summary>Expand this specification to exactly match a ref.</summary>
/// <remarks>
/// Expand this specification to exactly match a ref.
/// <p>
/// Callers must first verify the passed ref matches this specification,
/// otherwise expansion results may be unpredictable.
/// </remarks>
/// <param name="r">a ref that matched our destination specification.</param>
/// <returns>
/// a new specification expanded from provided ref name. Result
/// specification is wildcard if and only if provided ref name is
/// wildcard.
/// </returns>
public virtual NGit.Transport.RefSpec ExpandFromDestination(Ref r)
{
return ExpandFromDestination(r.GetName());
}
示例9: MatchDestination
/// <summary>Does this specification's destination description match the ref?</summary>
/// <param name="r">ref whose name should be tested.</param>
/// <returns>true if the names match; false otherwise.</returns>
public virtual bool MatchDestination(Ref r)
{
return Match(r.GetName(), GetDestination());
}
示例10: MatchSource
/// <summary>Does this specification's source description match the ref?</summary>
/// <param name="r">ref whose name should be tested.</param>
/// <returns>true if the names match; false otherwise.</returns>
public virtual bool MatchSource(Ref r)
{
return Match(r.GetName(), GetSource());
}
示例11: DeleteTrackingRef
private void DeleteTrackingRef(FetchResult result, BatchRefUpdate batch, RefSpec
spec, Ref localRef)
{
if (localRef.GetObjectId() == null)
{
return;
}
TrackingRefUpdate update = new TrackingRefUpdate(true, spec.GetSource(), localRef
.GetName(), localRef.GetObjectId(), ObjectId.ZeroId);
result.Add(update);
batch.AddCommand(update.AsReceiveCommand());
}
示例12: Want
/// <exception cref="NGit.Errors.TransportException"></exception>
private void Want(Ref src, RefSpec spec)
{
ObjectId newId = src.GetObjectId();
if (spec.GetDestination() != null)
{
TrackingRefUpdate tru = CreateUpdate(spec, newId);
if (newId.Equals(tru.GetOldObjectId()))
{
return;
}
localUpdates.AddItem(tru);
}
askFor.Put(newId, src);
FetchHeadRecord fhr = new FetchHeadRecord();
fhr.newValue = newId;
fhr.notForMerge = spec.GetDestination() != null;
fhr.sourceName = src.GetName();
fhr.sourceURI = transport.GetURI();
fetchHeadUpdates.AddItem(fhr);
}
示例13: 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. Use null to delete.</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, Ref srcRef, string remoteName, bool forceUpdate
, string localName, ObjectId expectedOldObjectId)
: this(localDb, srcRef != null
? srcRef.GetName() : null, srcRef != null ? srcRef.GetObjectId() : null, remoteName
, forceUpdate, localName, expectedOldObjectId)
{
}