public TranslateCommitAttemptResult Execute(CommitAttempt attempt) { var body = GetDecodedBody(attempt.RawBody); dynamic root = JObject.Parse(body); var commits = new List<CommitMessage>(); // TODO: make a copy instead of parse if can be done... dynamic rootWithoutCommits = root.DeepClone(); rootWithoutCommits.commits.RemoveAll(); foreach (var commitItem in root.commits) { var commit = new CommitMessage { MessageId = commitItem.id, Author = commitItem.author.name + " <" + commitItem.author.email + ">", Comment = commitItem.message, Date = commitItem.timestamp, }; dynamic fullContextCommit = rootWithoutCommits.DeepClone(); fullContextCommit.commits.Add(commitItem); commit.SourceCommit = fullContextCommit.ToString(); commits.Add(commit); } return new TranslateCommitAttemptResult { Success = true, Commits = commits }; }
private CommitMessage ParseXmlDocument(XDocument document) { CommitMessage commitMessage; try { var c = document.Descendants("CheckinEvent").FirstOrDefault(); commitMessage = new CommitMessage() { Author = c.Element("Committer").Value, Title = c.Element("Title").Value, Comment = c.Element("Comment").Value, //TODO: what time zone should we parse to? //Date = commit.Element("CreationDate").Value }; } catch { throw new InvalidTfsAttemptException(); } return commitMessage; }
private bool IsCommitValid(CommitMessage expected, CommitMessage actual) { var valid = false; // Don't nix my crazy separation. It's for debugging: valid = expected.Author == actual.Author; valid &= expected.Comment == actual.Comment; valid &= expected.SourceCommit == actual.SourceCommit; valid &= expected.Date == actual.Date; return valid; }