Esempio n. 1
0
        public static GitChangeSet Generate(string branch, string author, string email, string commitDate, string title, string files, string body)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                Console.WriteLine("No title provided for the commit");
                return(null);
            }

            List <string> issuesId = null;
            StringBuilder comments = new StringBuilder();

            issuesId = GitChangeSet.GetIssuesAndPopulateCommentsFromTitle(title, comments);

            if (issuesId == null || !issuesId.Any())
            {
                Console.WriteLine(string.Format("No valid title provided for the commit {0}", title));
                return(null);
            }

            comments.AppendLine(body);

            return(new GitChangeSet(
                       issuesId,
                       author,
                       email,
                       files.Split(Environment.NewLine.ToCharArray()).Where(r => !string.IsNullOrWhiteSpace(r)).ToList(),
                       commitDate,
                       comments.ToString(),
                       branch));
        }
        private void CreateComment(GitChangeSet changeSet, string ticket)
        {
            var issueRef = new IssueRef { id = ticket };

            var issue = this.Client.LoadIssue(issueRef);

            if (issue == null)
                return;

            this.Client.CreateComment(issueRef, changeSet.ToString());
        }
Esempio n. 3
0
        private static List <string> GetIssuesAndPopulateCommentsFromTitle(string title, StringBuilder comments)
        {
            List <string> result;

            if (title.Contains("[") && title.Contains("]"))
            {
                result = GetIssuesAndCommentsFromTitle(title, comments);
            }
            else
            {
                result = GitChangeSet.GetIssuesByCommaSplit(title);
            }

            return(result);
        }
 internal void AddComment(GitChangeSet changeSet)
 {
     foreach (var ticket in changeSet.JiraTickets)
         this.CreateComment(changeSet, ticket);
 }