public VersionVariables CalculateVersionVariables()
        {
            var arguments = options.Value;

            var cacheKey = cacheKeyFactory.Create(arguments.OverrideConfig);

            var versionVariables = arguments.NoCache ? default : gitVersionCache.LoadVersionVariablesFromDiskCache(cacheKey);

                                   if (versionVariables != null)
                                   {
                                       return(versionVariables);
                                   }

                                   versionVariables = ExecuteInternal(arguments);

                                   if (arguments.NoCache)
                                   {
                                       return(versionVariables);
                                   }
                                   try
                                   {
                                       gitVersionCache.WriteVariablesToDiskCache(cacheKey, versionVariables);
                                   }
                                   catch (AggregateException e)
                                   {
                                       log.Warning($"One or more exceptions during cache write:{System.Environment.NewLine}{e}");
                                   }

                                   return(versionVariables);
        }
예제 #2
0
        public VersionVariables CalculateVersionVariables()
        {
            gitPreparer.Prepare(); //we need to prepare the repository before using it for version calculation

            var gitVersionOptions = options.Value;

            var cacheKey = cacheKeyFactory.Create(gitVersionOptions.ConfigInfo.OverrideConfig);

            var versionVariables = gitVersionOptions.Settings.NoCache ? default : gitVersionCache.LoadVersionVariablesFromDiskCache(cacheKey);

                                   if (versionVariables != null)
                                   {
                                       return(versionVariables);
                                   }

                                   var semanticVersion = nextVersionCalculator.FindVersion();

                                   versionVariables = variableProvider.GetVariablesFor(semanticVersion, context.Configuration, context.IsCurrentCommitTagged);

                                   if (gitVersionOptions.Settings.NoCache)
                                   {
                                       return(versionVariables);
                                   }
                                   try
                                   {
                                       gitVersionCache.WriteVariablesToDiskCache(cacheKey, versionVariables);
                                   }
                                   catch (AggregateException e)
                                   {
                                       log.Warning($"One or more exceptions during cache write:{System.Environment.NewLine}{e}");
                                   }

                                   return(versionVariables);
        }
예제 #3
0
        private VersionVariables GetCachedGitVersionInfo(string targetBranch, string commitId, Config overrideConfig, bool noCache)
        {
            var cacheKey = cacheKeyFactory.Create(overrideConfig);

            var versionVariables = noCache ? default : gitVersionCache.LoadVersionVariablesFromDiskCache(cacheKey);

                                   if (versionVariables == null)
                                   {
                                       versionVariables = ExecuteInternal(targetBranch, commitId, overrideConfig);

                                       if (!noCache)
                                       {
                                           try
                                           {
                                               gitVersionCache.WriteVariablesToDiskCache(cacheKey, versionVariables);
                                           }
                                           catch (AggregateException e)
                                           {
                                               log.Warning($"One or more exceptions during cache write:{System.Environment.NewLine}{e}");
                                           }
                                       }
                                   }

                                   return(versionVariables);
        }