本文整理汇总了C#中Commit类的典型用法代码示例。如果您正苦于以下问题:C# Commit类的具体用法?C# Commit怎么用?C# Commit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Commit类属于命名空间,在下文中一共展示了Commit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ScanCommitMessagesForReleaseNotes
public SemanticReleaseNotes ScanCommitMessagesForReleaseNotes(GitReleaseNotesArguments arguments, Commit[] commitsToScan)
{
var repoParts = arguments.Repo.Split('/');
var organisation = repoParts[0];
var repository = repoParts[1];
var issueNumbersToScan = _issueNumberExtractor.GetIssueNumbers(arguments, commitsToScan, @"#(?<issueNumber>\d+)");
var since = commitsToScan.Select(c=>c.Author.When).Min();
var potentialIssues = _gitHubClient.Issue.GetForRepository(organisation, repository, new RepositoryIssueRequest
{
Filter = IssueFilter.All,
Since = since,
State = ItemState.Closed
}).Result;
var closedMentionedIssues = potentialIssues
.Where(i => issueNumbersToScan.Contains(i.Number.ToString(CultureInfo.InvariantCulture)))
.ToArray();
return new SemanticReleaseNotes(closedMentionedIssues.Select(i=>
{
var labels = i.Labels == null ? new string[0] : i.Labels.Select(l=>l.Name).ToArray();
return new ReleaseNoteItem(i.Title, string.Format("#{0}", i.Number), i.HtmlUrl, labels);
}));
}
示例2: GetCommits
/// <summary>
/// Get all the commits in a CVS log ordered by date.
/// </summary>
public IEnumerable<Commit> GetCommits()
{
var lookup = new Dictionary<string, Commit>();
using (var commitsByMessage = new CommitsByMessage(m_log))
{
foreach (var revision in m_fileRevisions)
{
if (revision.IsAddedOnAnotherBranch)
{
revision.File.BranchAddedOn = GetBranchAddedOn(revision.Message);
}
else if (revision.CommitId.Length == 0)
{
commitsByMessage.Add(revision);
}
else
{
Commit commit;
if (lookup.TryGetValue(revision.CommitId, out commit))
{
commit.Add(revision);
}
else
{
commit = new Commit(revision.CommitId) { revision };
lookup.Add(commit.CommitId, commit);
}
}
}
return lookup.Values.Concat(commitsByMessage.Resolve()).OrderBy(c => c.Time).ToList();
}
}
示例3: Commit
public virtual void Commit(Commit attempt)
{
lock (this.commits)
{
if (this.commits.Contains(attempt))
throw new DuplicateCommitException();
if (this.commits.Any(c => c.StreamId == attempt.StreamId && c.StreamRevision == attempt.StreamRevision))
throw new ConcurrencyException();
this.stamps[attempt.CommitId] = attempt.CommitStamp;
this.commits.Add(attempt);
lock (this.undispatched)
this.undispatched.Add(attempt);
lock (this.heads)
{
var head = this.heads.FirstOrDefault(x => x.StreamId == attempt.StreamId);
this.heads.Remove(head);
var snapshotRevision = head == null ? 0 : head.SnapshotRevision;
this.heads.Add(new StreamHead(attempt.StreamId, attempt.StreamRevision, snapshotRevision));
}
}
}
示例4: Commit
public virtual void Commit(Commit attempt)
{
if (!attempt.IsValid() || attempt.IsEmpty())
{
Logger.Debug(Resources.CommitAttemptFailedIntegrityChecks);
return;
}
foreach (var hook in _pipelineHooks)
{
Logger.Debug(Resources.InvokingPreCommitHooks, attempt.CommitId, hook.GetType());
if (hook.PreCommit(attempt))
{
continue;
}
Logger.Info(Resources.CommitRejectedByPipelineHook, hook.GetType(), attempt.CommitId);
return;
}
Logger.Info(Resources.CommittingAttempt, attempt.CommitId, attempt.Events.Count);
_persistence.Commit(attempt);
foreach (var hook in _pipelineHooks)
{
Logger.Debug(Resources.InvokingPostCommitPipelineHooks, attempt.CommitId, hook.GetType());
hook.PostCommit(attempt);
}
}
示例5: AppendVersion
private static void AppendVersion(Commit commit, int index)
{
var busMessage = commit.Events[index].Body as IMessage;
busMessage.SetHeader(AggregateIdKey, commit.StreamId.ToString());
busMessage.SetHeader(CommitVersionKey, commit.StreamRevision.ToString());
busMessage.SetHeader(EventVersionKey, GetSpecificEventVersion(commit, index).ToString());
}
示例6: Commit
public virtual void Commit(Commit attempt)
{
this.ThrowWhenDisposed();
Logger.Debug(Resources.AttemptingToCommit, attempt.CommitId, attempt.StreamId, attempt.CommitSequence);
lock (Commits)
{
if (Commits.Contains(attempt))
throw new DuplicateCommitException();
if (Commits.Any(c => c.StreamId == attempt.StreamId && c.StreamRevision == attempt.StreamRevision))
throw new ConcurrencyException();
Stamps[attempt.CommitId] = attempt.CommitStamp;
Commits.Add(attempt);
Undispatched.Add(attempt);
var head = Heads.FirstOrDefault(x => x.StreamId == attempt.StreamId);
Heads.Remove(head);
Logger.Debug(Resources.UpdatingStreamHead, attempt.StreamId);
var snapshotRevision = head == null ? 0 : head.SnapshotRevision;
Heads.Add(new StreamHead(attempt.StreamId, attempt.StreamRevision, snapshotRevision));
}
}
示例7: Context
protected override void Context()
{
alreadyCommitted = BuildCommitStub(HeadStreamRevision, HeadCommitSequence);
beyondEndOfStream = BuildCommitStub(BeyondEndOfStreamRevision, HeadCommitSequence + 1);
hook.PostCommit(alreadyCommitted);
}
示例8: ToGitObject
public IStorableObject ToGitObject(Repository repo, string sha)
{
using (GitObjectReader objectReader = new GitObjectReader(Content))
{
IStorableObject obj;
switch (Type)
{
case ObjectType.Commit:
obj = new Commit(repo, sha);
break;
case ObjectType.Tree:
obj = new Tree(repo, sha);
break;
case ObjectType.Blob:
obj = new Blob(repo, sha);
break;
case ObjectType.Tag:
obj = new Tag(repo, sha);
break;
default:
throw new NotImplementedException();
}
obj.Deserialize(objectReader);
return obj;
}
}
示例9: DeploymentsClientTests
public DeploymentsClientTests()
{
var github = Helper.GetAuthenticatedClient();
_deploymentsClient = github.Repository.Deployment;
_context = github.CreateRepositoryContext("public-repo").Result;
var blob = new NewBlob
{
Content = "Hello World!",
Encoding = EncodingType.Utf8
};
var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result;
var newTree = new NewTree();
newTree.Tree.Add(new NewTreeItem
{
Type = TreeType.Blob,
Mode = FileMode.File,
Path = "README.md",
Sha = blobResult.Sha
});
var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result;
var newCommit = new NewCommit("test-commit", treeResult.Sha);
_commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result;
}
示例10: SingleBranch_PlaysInSequence
public void SingleBranch_PlaysInSequence()
{
var now = DateTime.Now;
var file1 = new FileInfo("file1");
var file2 = new FileInfo("file2").WithBranch("branch", "1.1.0.2");
var commit0 = new Commit("id0") { Index = 1 }
.WithRevision(file1, "1.1", time: now)
.WithRevision(file2, "1.1", time: now);
var commit1 = new Commit("id1") { Index = 2 }
.WithRevision(file1, "1.2", time: now + TimeSpan.FromMinutes(2))
.WithRevision(file2, "1.2", time: now + TimeSpan.FromMinutes(2), mergepoint: "1.1.2.1");
var commit2 = new Commit("branch0") { Index = 3 }
.WithRevision(file2, "1.1.2.1", time: now + TimeSpan.FromMinutes(1));
var commits = new[] { commit0, commit1, commit2 };
var branchpoints = new Dictionary<string, Commit>()
{
{ "branch", commit0 }
};
var branches = new BranchStreamCollection(commits, branchpoints);
commit1.MergeFrom = commit2;
var player = new CommitPlayer(MockRepository.GenerateStub<ILogger>(), branches);
var result = player.Play().Select(c => c.CommitId).ToList();
Assert.IsTrue(result.SequenceEqual("id0", "branch0", "id1"));
}
示例11: Select
public virtual Commit Select(Commit committed)
{
foreach (var eventMessage in committed.Events)
eventMessage.Body = this.Convert(eventMessage.Body);
return committed;
}
示例12: CreateCommit
public String CreateCommit()
{
var reader = new StreamReader(Request.InputStream);
var data = reader.ReadToEnd();
reader.Close();
var dataValue = ParsePostData(data);
var userId = dataValue["userId"];
var repositoryId = int.Parse(dataValue["repositoryId"]);
var message = dataValue["message"];
Guid userGuid;
if (!IsUserAuthenticated(userId, out userGuid))
return null;
var repository = DataManager.GetInstance().GetRepository(repositoryId);
if (!repository.Owner.Equals(UserManager.GetInstance().GetUser(userGuid)))
return null;
if (String.IsNullOrWhiteSpace(message))
return null;
var commit = new Commit(UserManager.GetInstance().GetUser(userGuid), message);
var newCommit = DataManager.GetInstance().AddCommit(commit, repository);
var commitPath = GetTempCommitPath(repository, newCommit.Id);
Directory.CreateDirectory(commitPath);
return newCommit.Id.ToString(CultureInfo.InvariantCulture);
}
示例13: PreCommit
public virtual bool PreCommit(Commit attempt)
{
Logger.Debug(Resources.OptimisticConcurrencyCheck, attempt.StreamId);
Commit head = GetStreamHead(attempt.StreamId);
if (head == null)
{
return true;
}
if (head.CommitSequence >= attempt.CommitSequence)
{
throw new ConcurrencyException();
}
if (head.StreamRevision >= attempt.StreamRevision)
{
throw new ConcurrencyException();
}
if (head.CommitSequence < attempt.CommitSequence - 1)
{
throw new StorageException(); // beyond the end of the stream
}
if (head.StreamRevision < attempt.StreamRevision - attempt.Events.Count)
{
throw new StorageException(); // beyond the end of the stream
}
Logger.Debug(Resources.NoConflicts, attempt.StreamId);
return true;
}
示例14: DeploymentsClientTests
public DeploymentsClientTests()
{
var gitHubClient = Helper.GetAuthenticatedClient();
_deploymentsClient = gitHubClient.Repository.Deployment;
var newRepository = new NewRepository(Helper.MakeNameWithTimestamp("public-repo"))
{
AutoInit = true
};
_repository = gitHubClient.Repository.Create(newRepository).Result;
_repositoryOwner = _repository.Owner.Login;
var blob = new NewBlob
{
Content = "Hello World!",
Encoding = EncodingType.Utf8
};
var blobResult = gitHubClient.GitDatabase.Blob.Create(_repositoryOwner, _repository.Name, blob).Result;
var newTree = new NewTree();
newTree.Tree.Add(new NewTreeItem
{
Type = TreeType.Blob,
Mode = FileMode.File,
Path = "README.md",
Sha = blobResult.Sha
});
var treeResult = gitHubClient.GitDatabase.Tree.Create(_repositoryOwner, _repository.Name, newTree).Result;
var newCommit = new NewCommit("test-commit", treeResult.Sha);
_commit = gitHubClient.GitDatabase.Commit.Create(_repositoryOwner, _repository.Name, newCommit).Result;
}
示例15: Dispatch
public virtual void Dispatch(Commit commit)
{
ThreadPool.QueueUserWorkItem(state =>
{
this.bus.Publish(commit);
this.persistence.MarkCommitAsDispatched(commit);
});
}