LoadFromPath() публичный статический Метод

Creates a new SimpleRepositoryInfo based on a path (that can be below the folder with the '.git' sub folder).
public static LoadFromPath ( ILogger logger, string path, Action optionsChecker = null ) : SimpleRepositoryInfo
logger ILogger Logger that will be used.
path string The path to lookup.
optionsChecker Action /// Optional action that accepts the logger, a boolean that is true if a RepositoryInfo.xml has been /// found, and the that will be used. ///
Результат SimpleRepositoryInfo
Пример #1
0
 private SimpleRepositoryInfo GetRepositoryInfo(ILogger logger, Action <IWorkingFolderModifiedFile, ProjectFileContent> hook)
 {
     return(SimpleRepositoryInfo.LoadFromPath(logger, _solutionDir, (log, hasRepoXml, options) =>
     {
         options.IgnoreModifiedFileFullProcess = true;
         options.IgnoreModifiedFilePredicate = m =>
         {
             if (m.Path.EndsWith("project.json", StringComparison.Ordinal) &&
                 _projects.FirstOrDefault(p => PathComparer.Default.Equals(p.RelativeProjectFilePath, m.Path)) != null)
             {
                 var local = new ProjectFileContent(File.ReadAllText(m.FullPath), ContainsProject);
                 var committed = new ProjectFileContent(m.CommittedText, ContainsProject);
                 if (local.EqualsWithoutVersion(committed))
                 {
                     if (hook != null)
                     {
                         hook(m, committed);
                     }
                     return true;
                 }
             }
             return false;
         };
     }
                                              ));
 }
 public static SimpleRepositoryInfo GetSimpleRepositoryInfo(this ICakeContext context)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     return(SimpleRepositoryInfo.LoadFromPath(new Logger(context), context.Environment.WorkingDirectory.FullPath, (log, hasOptionFile, options) =>
     {
         if (!hasOptionFile)
         {
             log.Info("Using default options to read repository information.");
         }
         else
         {
             log.Info("Using RepositoryInfo.xml: " + options.ToXml().ToString());
         }
     }));
 }
Пример #3
0
        /// <summary>
        /// Reads version information.
        /// On errors, they are logged but the return of this task is always true to avoid blocking the build process.
        /// </summary>
        /// <returns>Always true.</returns>
        public override bool Execute()
        {
            try
            {
                var i = SimpleRepositoryInfo.LoadFromPath(new Logger(this), BuildEngine.ProjectFileOfTaskNode);
                GitSolutionDirectory = i.Info.GitSolutionDirectory;
                IsValidRelease       = i.IsValidRelease;
                IsValidCIBuild       = i.IsValidCIBuild;
                SemVer           = i.SemVer;
                NuGetVersion     = i.NuGetVersion;
                OriginalTagText  = i.OriginalTagText;
                Major            = i.Major;
                Minor            = i.Minor;
                Patch            = i.Patch;
                PreReleaseName   = i.PreReleaseName;
                PreReleaseNumber = i.PreReleaseNumber;
                PreReleaseFix    = i.PreReleaseFix;
                MajorMinor       = i.MajorMinor;
                MajorMinorPatch  = i.MajorMinorPatch;
                FileVersion      = i.FileVersion;
                OrderedVersion   = i.OrderedVersion;
                CurrentUserName  = i.CurrentUserName;
                CommitSha        = i.CommitSha;
                CommitDateUtc    = i.CommitDateUtc;

                if (i.Info.HasError)
                {
                    this.LogError(i.Info.RepositoryError ?? i.Info.ReleaseTagErrorText);
                }

                return(true);
            }
            catch (Exception exception)
            {
                this.LogError("Error occurred: " + exception);
                return(true);
            }
        }