本文整理汇总了C#中LibGit2Sharp.Commit类的典型用法代码示例。如果您正苦于以下问题:C# Commit类的具体用法?C# Commit怎么用?C# Commit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Commit类属于LibGit2Sharp命名空间,在下文中一共展示了Commit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CommitWrapper
public CommitWrapper(LibGit2Sharp.Commit commit)
{
this.commit = commit;
Sha = commit.Sha;
MessageShort = commit.MessageShort;
Message = commit.Message;
Author = commit.Author;
Committer = commit.Committer;
Tree = (async (i) => commit.Tree);
Parents = (async (i) => commit.Parents.Select((p) => new CommitWrapper(p)));
}
示例2: NumberOfCommitsOnBranchSinceCommit
public int NumberOfCommitsOnBranchSinceCommit(Branch branch, Commit commit)
{
var olderThan = branch.Tip.Committer.When;
return branch.Commits
.TakeWhile(x => x != commit)
.Count();
}
示例3: CalculateWhenMultipleParents
static Branch[] CalculateWhenMultipleParents(IRepository repository, Commit currentCommit, ref Branch currentBranch, Branch[] excludedBranches)
{
var parents = currentCommit.Parents.ToArray();
var branches = repository.Branches.Where(b => !b.IsRemote && b.Tip == parents[1]).ToList();
if (branches.Count == 1)
{
var branch = branches[0];
excludedBranches = new[]
{
currentBranch,
branch
};
currentBranch = branch;
}
else if (branches.Count > 1)
{
currentBranch = branches.FirstOrDefault(b => b.Name == "master") ?? branches.First();
}
else
{
var possibleTargetBranches = repository.Branches.Where(b => !b.IsRemote && b.Tip == parents[0]).ToList();
if (possibleTargetBranches.Count > 1)
{
currentBranch = possibleTargetBranches.FirstOrDefault(b => b.Name == "master") ?? possibleTargetBranches.First();
}
else
{
currentBranch = possibleTargetBranches.FirstOrDefault() ?? currentBranch;
}
}
Logger.WriteInfo("HEAD is merge commit, this is likely a pull request using " + currentBranch.Name + " as base");
return excludedBranches;
}
示例4: FindVersion
public SemanticVersion FindVersion(IRepository repository, Commit tip)
{
int major;
int minor;
int patch;
foreach (var tag in repository.TagsByDate(tip))
{
if (ShortVersionParser.TryParse(tag.Name, out major, out minor, out patch))
{
return BuildVersion(repository, tip, major, minor, patch);
}
}
var semanticVersion = new SemanticVersion();
string versionString;
if (MergeMessageParser.TryParse(tip, out versionString))
{
if (ShortVersionParser.TryParse(versionString, out major, out minor, out patch))
{
semanticVersion = BuildVersion(repository, tip, major, minor, patch);
}
}
semanticVersion.OverrideVersionManuallyIfNeeded(repository);
if (semanticVersion == null || semanticVersion.IsEmpty())
{
throw new WarningException("The head of a support branch should always be a merge commit if you follow gitflow. Please create one or work around this by tagging the commit with SemVer compatible Id.");
}
return semanticVersion;
}
示例5: CommitModel
public CommitModel(Commit commit)
{
Hash = commit.Id.Sha;
Who = commit.Author.Name;
When = commit.Author.When;
What = commit.MessageShort;
}
示例6: Visit
public void Visit(Commit commit)
{
Dictionary<DateTime, List<CommitDetails>> commitsOnDay = null;
if (!commitsByAuthor.TryGetValue(commit.Author.Email, out commitsOnDay))
{
commitsOnDay = new Dictionary<DateTime, List<CommitDetails>>();
commitsByAuthor.Add(commit.Author.Email, commitsOnDay);
}
DateTime commitDate = commit.Committer.When.DateTime.Round(TimeSpan.FromDays(1));
List<CommitDetails> commitDetails = null;
if (!commitsOnDay.TryGetValue(commitDate, out commitDetails))
{
commitDetails = new List<CommitDetails>();
commitsOnDay[commitDate] = commitDetails;
}
commitDetails.Add(new CommitDetails()
{
Id = commit.Id.Sha.Substring(0, 7),
Author = commit.Author.Email,
Message = commit.Message,
CommitTime = commit.Committer.When.DateTime
});
}
示例7: GetBranchConfiguration
public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit currentCommit, IRepository repository, bool onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList<Branch> excludedInheritBranches = null)
{
var matchingBranches = LookupBranchConfiguration(config, currentBranch);
if (matchingBranches.Length == 0)
{
var branchConfig = new BranchConfig();
ConfigurationProvider.ApplyBranchDefaults(config, branchConfig);
return new KeyValuePair<string, BranchConfig>(string.Empty, branchConfig);
}
if (matchingBranches.Length == 1)
{
var keyValuePair = matchingBranches[0];
var branchConfiguration = keyValuePair.Value;
if (branchConfiguration.Increment == IncrementStrategy.Inherit)
{
return InheritBranchConfiguration(onlyEvaluateTrackedBranches, repository, currentCommit, currentBranch, keyValuePair, branchConfiguration, config, excludedInheritBranches);
}
return keyValuePair;
}
const string format = "Multiple branch configurations match the current branch branchName of '{0}'. Matching configurations: '{1}'";
throw new Exception(string.Format(format, currentBranch.Name, string.Join(", ", matchingBranches.Select(b => b.Key))));
}
示例8: GetIntermediateCommits
private static IEnumerable<Commit> GetIntermediateCommits(IRepository repo, Commit baseCommit, Commit headCommit)
{
if (baseCommit == null) yield break;
if (intermediateCommitCache == null || intermediateCommitCache.LastOrDefault() != headCommit)
{
var filter = new CommitFilter
{
Since = headCommit,
SortBy = CommitSortStrategies.Topological | CommitSortStrategies.Reverse
};
intermediateCommitCache = repo.Commits.QueryBy(filter).ToList();
}
var found = false;
foreach (var commit in intermediateCommitCache)
{
if (commit.Sha == baseCommit.Sha)
found = true;
if (found)
yield return commit;
}
}
示例9: TagCommit
public TagCommit( Commit c, ReleaseTagVersion first )
{
Debug.Assert( c != null && first != null && first.IsValid );
_commitSha = c.Sha;
_contentSha = c.Tree.Sha;
_thisTag = first;
}
示例10: Archive
/// <summary>
/// Create a TAR archive of the given commit.
/// </summary>
/// <param name="odb">The object database.</param>
/// <param name="commit">commit.</param>
/// <param name="archivePath">The archive path.</param>
public static void Archive(this ObjectDatabase odb, Commit commit, string archivePath)
{
using (var output = new FileStream(archivePath, FileMode.Create))
using (var archiver = new TarArchiver(output))
{
odb.Archive(commit, archiver);
}
}
示例11: BaseVersion
public BaseVersion(string source, bool shouldIncrement, SemanticVersion semanticVersion, Commit baseVersionSource, string branchNameOverride)
{
Source = source;
ShouldIncrement = shouldIncrement;
SemanticVersion = semanticVersion;
BaseVersionSource = baseVersionSource;
BranchNameOverride = branchNameOverride;
}
示例12: FromCommit
public static GraphEntry FromCommit(GraphEntry previous, Commit commit)
{
if (previous == null) {
return CreateFirstEntry(commit);
}
return CreateEntryFromCommit(previous, commit);
}
示例13: GitCommit
internal GitCommit(Commit commit)
{
Sha = commit.Sha;
Author = new GitSignature(commit.Author.Email, commit.Author.Name, commit.Author.When);
Committer = new GitSignature(commit.Committer.Email, commit.Committer.Name, commit.Committer.When);
Message = commit.Message;
MessageShort = commit.MessageShort;
}
示例14: ContainsUser
private bool ContainsUser(Commit commit)
{
if (!string.IsNullOrEmpty(user))
{
return commit.Committer.Name.Equals(user);
}
return true;
}
示例15: BisectStep
public BisectStep(Commit c, int result)
{
commit = c;
if (-1 <= result && result <= 1)
i = result;
else
i = Result.NOTSET;
}