Exemple #1
0
        public SectionWriter(StringBuilder sectionLog, WriterOptions options)
        {
            /* options = extend({
            *   versionText: getVersion,
            *   patchVersionText: getPatchVersion,
            *   issueLink: getIssueLink.bind(null, options.repository),
            *   commitLink: getCommitLink.bind(null, options.repository)
            *  }, options || {}); */

            this.SectionLog = sectionLog;
            this.Options    = options;
            /* TODO: Add getVersion and getPatchVersion?? */
        }
Exemple #2
0
        public string WriteLog(List <CommitMessage> commits, WriterOptions options)
        {
            //Dictionary<string, List<CommitMessage>> sections = new Dictionary<string, List<CommitMessage>>() {
            //    { "fix", new List<CommitMessage>() },
            //    { "feat", new List<CommitMessage>() },
            //    { "breaks", new List<CommitMessage>() }
            //};

            if (options == null)
            {
                options = new WriterOptions();
            }

            Sections sections = new Sections();

            foreach (var commit in commits)
            {
                string component = commit.Component ?? EMPTY_COMPONENT;

                Section section;
                if (sections.TryGetSection(commit.Type, out section))
                {
                    {
                        section.Add(component, commit);
                    }
                }

                foreach (var breakMessage in commit.Breaks)
                {
                    sections.Breaks.Add(EMPTY_COMPONENT, new CommitMessage(commit.Hash, breakMessage));
                }
            }

            SectionWriter writer = new SectionWriter(options);

            /*
             * writer.header(options.version);
             * writer.section('Bug Fixes', sections.Fixesfix);
             * writer.section('Features', sections.Feats);
             * writer.section('Breaking Changes', sections.Breaks);
             * writer.end();
             */

            writer.Header(options.Version);
            writer.Section("Bug Fixes", sections.Fixes);
            writer.Section("Features", sections.Feats);
            writer.Section("Breaking Changes", sections.Breaks);

            return(writer.SectionLog.ToString());
        }
Exemple #3
0
 public SectionWriter(WriterOptions options) : this(new StringBuilder(), options)
 {
 }