Ejemplo n.º 1
0
        /// <summary>Compose the release note tag <paramref name="tag" /></summary>
        /// <param name="tag">The tag to compose a release note for</param>
        /// <param name="fromCommitExcluded">The last commit to include in the release note</param>
        /// <returns>The version description to be included in the ChangeLog</returns>
        private VersionDescription ComposeExistingVersionDescription(GitTag tag, string fromCommitExcluded)
        {
            var verDesc = new VersionDescription(tag);
            var content = this.ConcatCommitInfo(fromCommitExcluded, tag.CommitHash, Format, RefSpec);

            verDesc.Content.Append(content);

            return(verDesc);
        }
 protected Patch(VersionDescription from, VersionDescription to) {
     From = @from;
     To = to;
 }
 public GamePatch(VersionDescription from, VersionDescription to) : base(@from, to) {
     ChecksumFile = @"@IF\Addons\lib_core.pbo";
 }
 public EditionSensitiveDlcPatch(VersionDescriptionEdition from, VersionDescription to) : base(@from, to) {
     _from = from;
 }
 public DlcPatch(VersionDescription from, VersionDescription to) : base(@from, to) {
     ChecksumFile = @"@LIB_DLC_1\addons\lib_dlc_core.pbo";
 }
Ejemplo n.º 6
0
        /********************************************************************************************/
        /* ChangeLog example                                                                        */
        /********************************************************************************************/
        /* # THIS IS AN AUTOGENERATED FILE etc.                                                     */
        /* # CHANGE LOG : SuperMemo Assistant https://github.com/supermemo/SuperMemoAssistant/      */
        /*                                                                                          */
        /* [Next version (80ef5230d6ff7c25aa0668b60bfd8d960f064aba)]                                */
        /* - Added Notifications #53                                                                */
        /* - Added Notification + Option to restart on plugin crash                                 */
        /* - Added plugin labels #133                                                               */
        /* - Added ToolTips to UI icons #130                                                        */
        /*                                                                                          */
        /*                                                                                          */
        /* [2.0.3.309]                                                                              */
        /* - Added install destination folder in confirmation popup message #129 (Squirrel.Windows) */
        /* - Added cancel button + reset in Collection Selection #117                               */
        /* - Added a setup step to import collections from supermemo.ini #73                        */
        /*                                                                                          */
        /********************************************************************************************/
        /// <summary>
        ///   Reads [Next version (...)]'s commit hash and content, then construct a list of
        ///   revisions and their content
        /// </summary>
        /// <param name="stream">The ChangeLog stream</param>
        /// <param name="nextVersionDesc">[Next version]'s description</param>
        private Dictionary <string, VersionDescription> ReadChangeLog(Stream stream,
                                                                      out VersionDescription nextVersionDesc)
        {
            nextVersionDesc = null;

            VersionDescription currentVersion = null;
            var versionDescriptions           = new List <VersionDescription>();
            var lineNo = 0;

            using (var sr = new StreamReader(stream))
            {
                string line;

                while ((line = sr.ReadLine()) != null)
                {
                    lineNo++;

                    // Skip empty lines and comments (# xxx)
                    if (string.IsNullOrWhiteSpace(line) || line.TrimStart().StartsWith("#"))
                    {
                        continue;
                    }

                    var versionHeaderMatch = RE_ChangeLogVersionHeader.Match(line);

                    if (versionHeaderMatch.Success)
                    {
                        var version = versionHeaderMatch.Groups["Version"].Value;
                        var commit  = versionHeaderMatch.Groups["Commit"].Value;

                        switch (version.ToLower())
                        {
                        case "next version":
                            if (string.IsNullOrWhiteSpace(commit))
                            {
                                throw new ToolsException($"The [Next version] tag doesn't have a valid commit sha-1 hash: '{line}'", true);
                            }

                            currentVersion = nextVersionDesc = new VersionDescription(VersionDescription.NextVersionName, commit);

                            continue;

                        default:
                            currentVersion = new VersionDescription(version, commit);
                            versionDescriptions.Add(currentVersion);

                            continue;
                        }
                    }

                    if (currentVersion == null)
                    {
                        throw new ToolsException(
                                  $"The change log file cannot contain non-empty, non-comment lines outside of a [Version] section, line {lineNo}: '{line}'",
                                  true);
                    }

                    currentVersion.Content.AppendLine(line);
                }
            }

            return(versionDescriptions.ToDictionary(k => k.Name));
        }
Ejemplo n.º 7
0
        /// <inheritdoc />
        public override bool ExecuteTask()
        {
            bool analyzeFile               = File.Exists(ChangeLogFilePath) && PreserveChanges;
            var  versionDescMap            = new Dictionary <string, VersionDescription>();
            VersionDescription nextRelDesc = null;

            RefSpec.DefaultIfWhiteSpaceOrNull("master");

            //
            // Read and analyze existing ChangeLog
            using (var fs = File.Open(ChangeLogFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite))
                if (analyzeFile)
                {
                    versionDescMap = ReadChangeLog(fs, out nextRelDesc);
                }

            //
            // Synchronize Git and ChangeLog
            var tagCommitMap = this.GetTagCommitMap(RefSpec, TagSortField);

            // Remove versions that do not exist in the tag list. That might cause issue when switching between branches
            foreach (var versionName in versionDescMap.Keys
                     .Where(vn => tagCommitMap.ContainsKey(vn) == false)
                     .ToArray())
            {
                versionDescMap.Remove(versionName);
            }

            // Define the ordering of our ChangeLog
            foreach (var versionName in versionDescMap.Keys.ToArray())
            {
                versionDescMap[versionName].No = tagCommitMap[versionName].No;
            }

            var noCommitMap = tagCommitMap.Values.ToDictionary(k => k.No);

            // Add missing tags and compose their content
            foreach (var tagName in tagCommitMap.Keys
                     .Where(tn => versionDescMap.ContainsKey(tn) == false)
                     .ToArray())
            {
                var tag     = tagCommitMap[tagName];
                var prevTag = tag.No > 0
          ? noCommitMap[tag.No - 1]
          : null;

                versionDescMap[tagName] = ComposeExistingVersionDescription(tag, prevTag?.CommitHash);
            }

            //
            // Create the next version release note
            var allVersions        = versionDescMap.Values.ToList();
            var lastTag            = versionDescMap.Values.OrderByDescending(v => v.No).FirstOrDefault();
            var fromCommitExcluded = nextRelDesc?.CommitHash ?? lastTag?.CommitHash;
            var toCommitIncluded   = RefSpec;
            var toCommitExpanded   = this.ExpandToCommitHash(toCommitIncluded);

            if (toCommitExpanded != fromCommitExcluded)
            {
                string releaseNote = this.ConcatCommitInfo(fromCommitExcluded, toCommitIncluded);

                if (nextRelDesc != null && string.IsNullOrWhiteSpace(nextRelDesc.Content.ToString()) == false)
                {
                    releaseNote += "\n" + nextRelDesc.Content;
                }

                nextRelDesc = new VersionDescription(VersionDescription.NextVersionName,
                                                     toCommitExpanded,
                                                     (lastTag?.No ?? 0) + 1);
                nextRelDesc.Content.Append(releaseNote);

                allVersions.Add(nextRelDesc);
            }

            else
            {
                nextRelDesc = lastTag;
            }


            //
            // Save ChangeLog
            WriteChangeLog(allVersions);

            CurrentVersionReleaseNotes    = nextRelDesc?.Content.ToString();
            CurrentVersionHasReleaseNotes = string.IsNullOrWhiteSpace(nextRelDesc?.Content.ToString()) == false;

            //
            // Write NuSpec if required
            if (string.IsNullOrWhiteSpace(NuSpecFilePath) == false && File.Exists(NuSpecFilePath) && nextRelDesc != null)
            {
                this.WriteNuSpec(NuSpecFilePath, "Replace", nuSpecProperty: "releaseNotes", nuSpecValue: nextRelDesc.Content.ToString());
            }

            return(true);
        }
Ejemplo n.º 8
0
 protected Patch(VersionDescription from, VersionDescription to)
 {
     From = from;
     To   = to;
 }
Ejemplo n.º 9
0
 public GamePatch(VersionDescription from, VersionDescription to) : base(from, to)
 {
     ChecksumFile = @"@IF\Addons\lib_core.pbo";
 }
Ejemplo n.º 10
0
 public EditionSensitiveDlcPatch(VersionDescriptionEdition from, VersionDescription to) : base(from, to)
 {
     _from = from;
 }
Ejemplo n.º 11
0
 public DlcPatch(VersionDescription from, VersionDescription to) : base(from, to)
 {
     ChecksumFile = @"@LIB_DLC_1\addons\lib_dlc_core.pbo";
 }