Exemplo n.º 1
0
        public ContentItem Get(int id, VersionOptions options) {
            var record = _contentStorageManager
                .Query<ContentItemVersionRecord>(x => _query(x, id, options))
                .OrderBy(x => x.Number)
                .LastOrDefault();

            return new ContentItem { VersionRecord = record };
        }
        public static IApplicationBuilder UseDatabaseInstaller(this IApplicationBuilder app, Action<VersionOptions> options)
        {
            if (app == null)
            {
                throw new ArgumentNullException(nameof(app));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var versionOptions = new VersionOptions();
            options.Invoke(versionOptions);

            return app.UseMiddleware<DatabaseInstallerMiddleware>(versionOptions);
        }
    public void Equality()
    {
        var vo1a = new VersionOptions
        {
            Version = new SemanticVersion("1.2"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version("1.3")),
            BuildNumberOffset = 2,
        };
        var vo1b = new VersionOptions
        {
            Version = new SemanticVersion("1.2"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version("1.3")),
            BuildNumberOffset = 2,
        };

        var vo2VaryAV = new VersionOptions
        {
            Version = new SemanticVersion("1.2"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version("1.4")),
        };
        var vo2VaryV = new VersionOptions
        {
            Version = new SemanticVersion("1.4"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version("1.3")),
        };
        var vo2VaryO = new VersionOptions
        {
            Version = new SemanticVersion("1.2"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version("1.3")),
            BuildNumberOffset = 3,
        };

        Assert.Equal(vo1a, vo1b);
        Assert.NotEqual(vo2VaryAV, vo1a);
        Assert.NotEqual(vo2VaryV, vo1a);
        Assert.NotEqual(vo2VaryO, vo1a);
    }
    public async Task GetBuildVersion_In_Git_With_Version_File_In_Root_And_Project_In_Root_Works()
    {
        var rootVersionSpec = new VersionOptions
        {
            Version = SemanticVersion.Parse("14.1"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version(14, 0)),
        };

        this.WriteVersionFile(rootVersionSpec);
        this.InitializeSourceControl();
        this.AddCommits(this.random.Next(15));
        var buildResult = await this.BuildAsync(this.testProjectInRoot);
        this.AssertStandardProperties(rootVersionSpec, buildResult);
    }
Exemplo n.º 5
0
 public ContentItem Restore(ContentItem contentItem, VersionOptions options)
 {
     return(_decoratedService.Restore(contentItem, options));
 }
        /// <summary>
        /// Encodes a commit from history in a <see cref="Version"/>
        /// so that the original commit can be found later.
        /// </summary>
        /// <param name="commit">The commit whose ID and position in history is to be encoded.</param>
        /// <param name="versionOptions">The version options applicable at this point (either from commit or working copy).</param>
        /// <param name="repoRelativeProjectDirectory">The repo-relative project directory for which to calculate the version.</param>
        /// <param name="versionHeight">
        /// The version height, previously calculated by a call to <see cref="GetVersionHeight(Commit, string)"/>
        /// with the same value for <paramref name="repoRelativeProjectDirectory"/>.
        /// </param>
        /// <returns>
        /// A version whose <see cref="Version.Build"/> and
        /// <see cref="Version.Revision"/> components are calculated based on the commit.
        /// </returns>
        /// <remarks>
        /// In the returned version, the <see cref="Version.Build"/> component is
        /// the height of the git commit while the <see cref="Version.Revision"/>
        /// component is the first four bytes of the git commit id (forced to be a positive integer).
        /// </remarks>
        /// <returns></returns>
        private static Version GetIdAsVersionHelper(Commit commit, VersionOptions versionOptions, string repoRelativeProjectDirectory, int? versionHeight)
        {
            var baseVersion = versionOptions?.Version?.Version ?? Version0;

            // The compiler (due to WinPE header requirements) only allows 16-bit version components,
            // and forbids 0xffff as a value.
            // The build number is set to the git height. This helps ensure that
            // within a major.minor release, each patch has an incrementing integer.
            // The revision is set to the first two bytes of the git commit ID.
            if (!versionHeight.HasValue)
            {
                versionHeight = commit != null
                    ? commit.GetHeight(c => CommitMatchesMajorMinorVersion(c, baseVersion, repoRelativeProjectDirectory))
                    : 0;
            }

            int build = versionHeight.Value + (versionOptions?.BuildNumberOffset ?? 0);
            Verify.Operation(build <= MaximumBuildNumberOrRevisionComponent, "Git height is {0}, which is greater than the maximum allowed {0}.", build, MaximumBuildNumberOrRevisionComponent);
            int revision = commit != null
                ? Math.Min(MaximumBuildNumberOrRevisionComponent, commit.GetTruncatedCommitIdAsUInt16())
                : 0;

            return new Version(baseVersion.Major, baseVersion.Minor, build, revision);
        }
    private void AssertPathHasVersion(Commit commit, string absolutePath, VersionOptions expected)
    {
        var actual = VersionFile.GetVersion(absolutePath);
        Assert.Equal(expected, actual);

        // Pass in the repo-relative path to ensure the commit is used as the data source.
        string relativePath = absolutePath.Substring(this.RepoPath.Length).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
        actual = VersionFile.GetVersion(commit, relativePath);
        Assert.Equal(expected, actual);
    }
    public async Task PublicRelease_RegEx_SatisfiedByCheckedOutBranch()
    {
        var versionOptions = new VersionOptions
        {
            Version = SemanticVersion.Parse("1.0"),
            PublicReleaseRefSpec = new string[] { "^refs/heads/release$" },
        };
        this.WriteVersionFile(versionOptions);
        this.InitializeSourceControl();

        // Check out a branch that conforms.
        var releaseBranch = this.Repo.CreateBranch("release");
        this.Repo.Checkout(releaseBranch);
        var buildResult = await this.BuildAsync();
        Assert.True(buildResult.PublicRelease);
        AssertStandardProperties(versionOptions, buildResult);
    }
Exemplo n.º 9
0
 public ContentItem Get(int id, VersionOptions options, QueryHints hints)
 {
     return(_decoratedService.Get(id, options, hints));
 }
 private static Version GetExpectedAssemblyVersion(VersionOptions versionOptions, Version version)
 {
     var assemblyVersionPrecision = versionOptions.AssemblyVersion?.Precision ?? VersionOptions.VersionPrecision.Minor;
     int assemblyVersionBuild = assemblyVersionPrecision >= VersionOptions.VersionPrecision.Build ? version.Build : 0;
     int assemblyVersionRevision = assemblyVersionPrecision >= VersionOptions.VersionPrecision.Revision ? version.Revision : 0;
     Version assemblyVersion = (versionOptions.AssemblyVersion?.Version ?? versionOptions.Version.Version).EnsureNonNegativeComponents();
     assemblyVersion = new Version(assemblyVersion.Major, assemblyVersion.Minor, assemblyVersionBuild, assemblyVersionRevision);
     return assemblyVersion;
 }
Exemplo n.º 11
0
 public ShippingProviderPart GetProvider(int ProviderId, int?VersionRecordId = null)
 {
     return(_contentManager.Get <ShippingProviderPart>(ProviderId, VersionRecordId.HasValue ? VersionOptions.VersionRecord(VersionRecordId.Value) : VersionOptions.Published));
 }
Exemplo n.º 12
0
        private static int OnInstallCommand(string path, string version, IReadOnlyList <string> source)
        {
            if (!SemanticVersion.TryParse(string.IsNullOrEmpty(version) ? DefaultVersionSpec : version, out var semver))
            {
                Console.Error.WriteLine($"\"{version}\" is not a semver-compliant version spec.");
                return((int)ExitCodes.InvalidVersionSpec);
            }

            var options = new VersionOptions
            {
                Version = semver,
                PublicReleaseRefSpec = new string[]
                {
                    @"^refs/heads/master$",
                    @"^refs/heads/v\d+(?:\.\d+)?$",
                },
                CloudBuild = new VersionOptions.CloudBuildOptions
                {
                    BuildNumber = new VersionOptions.CloudBuildNumberOptions
                    {
                        Enabled = true,
                    },
                },
            };
            string searchPath = GetSpecifiedOrCurrentDirectoryPath(path);

            if (!Directory.Exists(searchPath))
            {
                Console.Error.WriteLine("\"{0}\" is not an existing directory.", searchPath);
                return((int)ExitCodes.NoGitRepo);
            }

            using var context = GitContext.Create(searchPath, writable: true);
            if (!context.IsRepository)
            {
                Console.Error.WriteLine("No git repo found at or above: \"{0}\"", searchPath);
                return((int)ExitCodes.NoGitRepo);
            }

            if (string.IsNullOrEmpty(path))
            {
                path = context.WorkingTreePath;
            }

            var existingOptions = context.VersionFile.GetVersion();

            if (existingOptions != null)
            {
                if (!string.IsNullOrEmpty(version))
                {
                    var setVersionExitCode = OnSetVersionCommand(path, version);
                    if (setVersionExitCode != (int)ExitCodes.OK)
                    {
                        return(setVersionExitCode);
                    }
                }
            }
            else
            {
                string versionJsonPath = context.VersionFile.SetVersion(path, options);
                context.Stage(versionJsonPath);
            }

            // Create/update the Directory.Build.props file in the directory of the version.json file to add the NB.GV package.
            string             directoryBuildPropsPath = Path.Combine(path, "Directory.Build.props");
            ProjectRootElement propsFile = File.Exists(directoryBuildPropsPath)
                ? ProjectRootElement.Open(directoryBuildPropsPath)
                : ProjectRootElement.Create(directoryBuildPropsPath);

            const string PackageReferenceItemType = "PackageReference";

            if (!propsFile.Items.Any(i => i.ItemType == PackageReferenceItemType && i.Include == PackageId))
            {
                // Validate given sources
                foreach (var src in source)
                {
                    // TODO: Can declare Option<Uri> to validate argument during parsing.
                    if (!Uri.TryCreate(src, UriKind.Absolute, out var _))
                    {
                        Console.Error.WriteLine($"\"{src}\" is not a valid NuGet package source.");
                        return((int)ExitCodes.InvalidNuGetPackageSource);
                    }
                }

                string packageVersion = GetLatestPackageVersionAsync(PackageId, path, source).GetAwaiter().GetResult();
                if (string.IsNullOrEmpty(packageVersion))
                {
                    string verifyPhrase = source.Any()
                        ? "Please verify the given 'source' option(s)."
                        : "Please verify the package sources in the NuGet.Config files.";
                    Console.Error.WriteLine($"Latest stable version of the {PackageId} package could not be determined. " + verifyPhrase);
                    return((int)ExitCodes.PackageIdNotFound);
                }

                var item = propsFile.AddItem(
                    PackageReferenceItemType,
                    PackageId,
                    new Dictionary <string, string>
                {
                    { "Version", packageVersion },
                    { "PrivateAssets", "all" },
                });
                item.Condition = "!Exists('packages.config')";

                propsFile.Save(directoryBuildPropsPath);
            }

            context.Stage(directoryBuildPropsPath);

            return((int)ExitCodes.OK);
        }
Exemplo n.º 13
0
 public int Count(ForumPart forumPart, VersionOptions versionOptions)
 {
     return(GetParentQuery(forumPart, versionOptions).Count());
 }
Exemplo n.º 14
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart, int skip, int count, VersionOptions versionOptions)
 {
     return(GetParentQuery(forumPart, versionOptions)
            .Join <ThreadPartRecord>()
            .OrderByDescending(o => o.IsSticky)
            .Join <CommonPartRecord>()
            .OrderByDescending(o => o.ModifiedUtc)
            .ForPart <ThreadPart>()
            .Slice(skip, count)
            .ToList());
 }
Exemplo n.º 15
0
 public IEnumerable <ThreadPart> Get(ForumPart forumPart, VersionOptions versionOptions)
 {
     return(Get(forumPart, 0, 0, versionOptions));
 }
 public async Task GetBuildVersion_CustomAssemblyVersionPrecision(VersionOptions.VersionPrecision precision)
 {
     var versionOptions = new VersionOptions
     {
         Version = new SemanticVersion("14.1"),
         AssemblyVersion = new VersionOptions.AssemblyVersionOptions
         {
             Precision = precision,
         },
     };
     this.WriteVersionFile(versionOptions);
     this.InitializeSourceControl();
     var buildResult = await this.BuildAsync(this.testProject);
     this.AssertStandardProperties(versionOptions, buildResult);
 }
Exemplo n.º 17
0
 public Task CreateAsync(ContentItem contentItem, VersionOptions options, bool invokeUpdateCallbacks = false) => throw new System.NotImplementedException();
    public async Task BuildNumber_SetInCI(VersionOptions versionOptions, IReadOnlyDictionary<string, string> properties, string expectedBuildNumberMessage)
    {
        this.WriteVersionFile(versionOptions);
        this.InitializeSourceControl();

        foreach (var property in properties)
        {
            this.globalProperties[property.Key] = property.Value;
        }

        var buildResult = await this.BuildAsync(this.testProject);
        AssertStandardProperties(versionOptions, buildResult);
        expectedBuildNumberMessage = expectedBuildNumberMessage.Replace("{CLOUDBUILDNUMBER}", buildResult.CloudBuildNumber);
        Assert.Contains(expectedBuildNumberMessage, buildResult.LoggedEvents.Select(e => e.Message.TrimEnd()));
    }
Exemplo n.º 19
0
 public Task CreateAsync(ContentItem contentItem, VersionOptions options) => throw new NotImplementedException();
Exemplo n.º 20
0
        protected Commit WriteVersionFile(VersionOptions versionData, string relativeDirectory = null)
        {
            Requires.NotNull(versionData, nameof(versionData));

            if (relativeDirectory == null)
            {
                relativeDirectory = string.Empty;
            }

            string versionFilePath = VersionFile.SetVersion(Path.Combine(this.RepoPath, relativeDirectory), versionData);
            return this.CommitVersionFile(versionFilePath, versionData.Version.ToString());
        }
Exemplo n.º 21
0
 public Task <ContentItem> GetAsync(string id, VersionOptions options) => throw new NotImplementedException();
Exemplo n.º 22
0
 private IContentQuery <CommonPart, CommonPartRecord> GetParentQuery(IContent parentPart, VersionOptions versionOptions)
 {
     return(_contentManager.Query <CommonPart, CommonPartRecord>(versionOptions)
            .Where(cpr => cpr.Container == parentPart.ContentItem.Record));
 }
        /// <summary>
        /// Indexes a batch of content items
        /// </summary>
        /// <returns>
        /// <c>true</c> if there are more items to process; otherwise, <c>false</c>.
        /// </returns>
        private bool BatchIndex(string indexName, string settingsFilename, IndexSettings indexSettings)
        {
            var addToIndex      = new List <IDocumentIndex>();
            var deleteFromIndex = new List <int>();

            // Rebuilding the index ?
            if (indexSettings.Mode == IndexingMode.Rebuild)
            {
                Logger.Information("Rebuilding index");
                _indexingStatus = IndexingStatus.Rebuilding;

                // load all content items
                var contentItems = _contentRepository
                                   .Fetch(
                    versionRecord => versionRecord.Published && versionRecord.Id > indexSettings.LastContentId,
                    order => order.Asc(versionRecord => versionRecord.Id))
                                   .Take(ContentItemsPerLoop)
                                   .Select(versionRecord => _contentManager.Get(versionRecord.ContentItemRecord.Id, VersionOptions.VersionRecord(versionRecord.Id)))
                                   .Distinct()
                                   .ToList();

                // if no more elements to index, switch to update mode
                if (contentItems.Count == 0)
                {
                    indexSettings.Mode = IndexingMode.Update;
                }

                foreach (var item in contentItems)
                {
                    try {
                        IDocumentIndex documentIndex = ExtractDocumentIndex(item);

                        if (documentIndex != null && documentIndex.IsDirty)
                        {
                            addToIndex.Add(documentIndex);
                        }

                        indexSettings.LastContentId = item.VersionRecord.Id;
                    }
                    catch (Exception ex) {
                        Logger.Warning(ex, "Unable to index content item #{0} during rebuild", item.Id);
                    }
                }
            }

            if (indexSettings.Mode == IndexingMode.Update)
            {
                Logger.Information("Updating index");
                _indexingStatus = IndexingStatus.Updating;

                var indexingTasks = _taskRepository
                                    .Fetch(x => x.Id > indexSettings.LastIndexedId)
                                    .OrderBy(x => x.Id)
                                    .Take(ContentItemsPerLoop)
                                    .GroupBy(x => x.ContentItemRecord.Id)
                                    .Select(group => new { TaskId = group.Max(task => task.Id), Delete = group.Last().Action == IndexingTaskRecord.Delete, Id = group.Key, ContentItem = _contentManager.Get(group.Key, VersionOptions.Published) })
                                    .OrderBy(x => x.TaskId)
                                    .ToArray();

                foreach (var item in indexingTasks)
                {
                    try {
                        // item.ContentItem can be null if the content item has been deleted
                        IDocumentIndex documentIndex = ExtractDocumentIndex(item.ContentItem);

                        if (documentIndex == null || item.Delete)
                        {
                            deleteFromIndex.Add(item.Id);
                        }
                        else if (documentIndex.IsDirty)
                        {
                            addToIndex.Add(documentIndex);
                        }

                        indexSettings.LastIndexedId = item.TaskId;
                    }
                    catch (Exception ex) {
                        Logger.Warning(ex, "Unable to index content item #{0} during update", item.Id);
                    }
                }
            }

            // save current state of the index
            indexSettings.LastIndexedUtc = _clock.UtcNow;
            _appDataFolder.CreateFile(settingsFilename, indexSettings.ToXml());

            if (deleteFromIndex.Count == 0 && addToIndex.Count == 0)
            {
                // nothing more to do
                _indexingStatus = IndexingStatus.Idle;
                return(false);
            }

            // save new and updated documents to the index
            try {
                if (addToIndex.Count > 0)
                {
                    _indexProvider.Store(indexName, addToIndex);
                    Logger.Information("Added content items to index: {0}", addToIndex.Count);
                }
            }
            catch (Exception ex) {
                Logger.Warning(ex, "An error occured while adding a document to the index");
            }

            // removing documents from the index
            try {
                if (deleteFromIndex.Count > 0)
                {
                    _indexProvider.Delete(indexName, deleteFromIndex);
                    Logger.Information("Added content items to index: {0}", addToIndex.Count);
                }
            }
            catch (Exception ex) {
                Logger.Warning(ex, "An error occured while removing a document from the index");
            }

            return(true);
        }
    public void SetVersion_WritesSimplestFile(string version, string assemblyVersion, VersionOptions.VersionPrecision precision, int buildNumberOffset, string expectedJson)
    {
        var versionOptions = new VersionOptions
        {
            Version = SemanticVersion.Parse(version),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(assemblyVersion != null ? new Version(assemblyVersion) : null, precision),
            BuildNumberOffset = buildNumberOffset,
        };
        string pathWritten = VersionFile.SetVersion(this.RepoPath, versionOptions);
        string actualFileContent = File.ReadAllText(pathWritten);
        this.Logger.WriteLine(actualFileContent);

        string normalizedFileContent = JsonConvert.SerializeObject(JsonConvert.DeserializeObject(actualFileContent));
        Assert.Equal(expectedJson, normalizedFileContent);
    }
        public IEnumerable <TermPart> GetTermsForContentItem(int contentItemId, string field = null, VersionOptions versionOptions = null)
        {
            var termIds = String.IsNullOrEmpty(field)
                ? _termContentItemRepository.Fetch(x => x.TermsPartRecord.ContentItemRecord.Id == contentItemId).Select(t => t.TermRecord.Id).ToArray()
                : _termContentItemRepository.Fetch(x => x.TermsPartRecord.Id == contentItemId && x.Field == field).Select(t => t.TermRecord.Id).ToArray();

            return(_contentManager.GetMany <TermPart>(termIds, versionOptions ?? VersionOptions.Published, QueryHints.Empty));
        }
Exemplo n.º 26
0
 public RestoreContentContext(ContentItem contentItem, VersionOptions versionOptions) : base(contentItem) {
     VersionOptions = versionOptions;
 }
Exemplo n.º 27
0
 public new virtual ContentItem Get(int id, VersionOptions options)
 {
     return(Get(id, options, QueryHints.Empty));
 }
    public void VersionJson_Inheritance(bool commitInSourceControl)
    {
        if (commitInSourceControl)
        {
            this.InitializeSourceControl();
        }

        VersionOptions level1, level2, level3, level2NoInherit, level2InheritButResetVersion;
        this.WriteVersionFile(
            level1 = new VersionOptions
            {
                Version = SemanticVersion.Parse("14.2"),
                AssemblyVersion = new VersionOptions.AssemblyVersionOptions { Precision = VersionOptions.VersionPrecision.Major },
            });
        this.WriteVersionFile(
            level2 = new VersionOptions
            {
                Inherit = true,
                AssemblyVersion = new VersionOptions.AssemblyVersionOptions { Precision = VersionOptions.VersionPrecision.Minor },
            },
            "foo");
        this.WriteVersionFile(
            level3 = new VersionOptions
            {
                Inherit = true,
                VersionHeightOffset = 1,
            },
            "foo/bar");
        this.WriteVersionFile(
            level2NoInherit = new VersionOptions
            {
                Version = SemanticVersion.Parse("10.1"),
            },
            "noInherit");
        this.WriteVersionFile(
            level2InheritButResetVersion = new VersionOptions
            {
                Inherit = true,
                Version = SemanticVersion.Parse("8.2"),
            },
            "inheritWithVersion");

        VersionOptions GetOption(string path)
        {
            using var context = this.CreateGitContext(Path.Combine(this.RepoPath, path));
            return context.VersionFile.GetVersion();
        }
        
        var level1Options = GetOption(string.Empty);
        Assert.False(level1Options.Inherit);

        var level2Options = GetOption("foo");
        Assert.Equal(level1.Version.Version.Major, level2Options.Version.Version.Major);
        Assert.Equal(level1.Version.Version.Minor, level2Options.Version.Version.Minor);
        Assert.Equal(level2.AssemblyVersion.Precision, level2Options.AssemblyVersion.Precision);
        Assert.True(level2Options.Inherit);

        var level3Options = GetOption("foo/bar");
        Assert.Equal(level1.Version.Version.Major, level3Options.Version.Version.Major);
        Assert.Equal(level1.Version.Version.Minor, level3Options.Version.Version.Minor);
        Assert.Equal(level2.AssemblyVersion.Precision, level3Options.AssemblyVersion.Precision);
        Assert.Equal(level2.AssemblyVersion.Precision, level3Options.AssemblyVersion.Precision);
        Assert.Equal(level3.VersionHeightOffset, level3Options.VersionHeightOffset);
        Assert.True(level3Options.Inherit);

        var level2NoInheritOptions = GetOption("noInherit");
        Assert.Equal(level2NoInherit.Version, level2NoInheritOptions.Version);
        Assert.Equal(VersionOptions.DefaultVersionPrecision, level2NoInheritOptions.AssemblyVersionOrDefault.PrecisionOrDefault);
        Assert.False(level2NoInheritOptions.Inherit);

        var level2InheritButResetVersionOptions = GetOption("inheritWithVersion");
        Assert.Equal(level2InheritButResetVersion.Version, level2InheritButResetVersionOptions.Version);
        Assert.True(level2InheritButResetVersionOptions.Inherit);

        if (commitInSourceControl)
        {
            int totalCommits = this.LibGit2Repository.Head.Commits.Count();

            // The version height should be the same for all those that inherit the version from the base,
            // even though the inheriting files were introduced in successive commits.
            Assert.Equal(totalCommits, this.GetVersionHeight());
            Assert.Equal(totalCommits, this.GetVersionHeight("foo"));
            Assert.Equal(totalCommits, this.GetVersionHeight("foo/bar"));

            // These either don't inherit, or inherit but reset versions, so the commits were reset.
            Assert.Equal(2, this.GetVersionHeight("noInherit"));
            Assert.Equal(1, this.GetVersionHeight("inheritWithVersion"));
        }
    }
Exemplo n.º 29
0
        public ContentItem Get(int id, VersionOptions versionOptions)
        {
            var blogPart = _contentManager.Get <BlogPart>(id, versionOptions);

            return(blogPart == null ? null : blogPart.ContentItem);
        }
Exemplo n.º 30
0
 public IEnumerable <T> GetMany <T>(IEnumerable <int> ids, VersionOptions options, QueryHints hints) where T : class, IContent
 {
     return(_decoratedService.GetMany <T>(ids, options, hints));
 }
Exemplo n.º 31
0
 public new IContentQuery <TPart, TRecord> ForVersion(VersionOptions options)
 {
     throw new NotImplementedException();
 }
 public async Task GetBuildVersion_CustomAssemblyVersion()
 {
     this.WriteVersionFile("14.0");
     this.InitializeSourceControl();
     var versionOptions = new VersionOptions
     {
         Version = new SemanticVersion(new Version(14, 1)),
         AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version(14, 0)),
     };
     this.WriteVersionFile(versionOptions);
     var buildResult = await this.BuildAsync(this.testProject);
     this.AssertStandardProperties(versionOptions, buildResult);
 }
Exemplo n.º 33
0
 private static Version GetAssemblyVersion(Version version, VersionOptions versionOptions)
 {
     var assemblyVersion = versionOptions?.AssemblyVersion?.Version ?? new System.Version(version.Major, version.Minor);
     assemblyVersion = new System.Version(
         assemblyVersion.Major,
         assemblyVersion.Minor,
         versionOptions?.AssemblyVersion?.Precision >= VersionOptions.VersionPrecision.Build ? version.Build : 0,
         versionOptions?.AssemblyVersion?.Precision >= VersionOptions.VersionPrecision.Revision ? version.Revision : 0);
     return assemblyVersion;
 }
    public async Task CloudBuildVariables_SetInCI(IReadOnlyDictionary<string, string> properties, string expectedMessage)
    {
        foreach (var property in properties)
        {
            this.globalProperties[property.Key] = property.Value;
        }

        string keyName = "n1";
        string value = "v1";
        this.testProject.AddItem("CloudBuildVersionVars", keyName, new Dictionary<string, string> { { "Value", value } });

        string alwaysExpectedMessage = expectedMessage
            .Replace("{NAME}", keyName)
            .Replace("{VALUE}", value);

        var versionOptions = new VersionOptions
        {
            Version = SemanticVersion.Parse("1.0"),
            CloudBuild = new VersionOptions.CloudBuildOptions { SetVersionVariables = true },
        };
        this.WriteVersionFile(versionOptions);
        this.InitializeSourceControl();

        var buildResult = await this.BuildAsync(this.testProject);
        AssertStandardProperties(versionOptions, buildResult);
        string conditionallyExpectedMessage = expectedMessage
            .Replace("{NAME}", "GitBuildVersion")
            .Replace("{VALUE}", buildResult.BuildVersion);
        Assert.Contains(alwaysExpectedMessage, buildResult.LoggedEvents.Select(e => e.Message.TrimEnd()));
        Assert.Contains(conditionallyExpectedMessage, buildResult.LoggedEvents.Select(e => e.Message.TrimEnd()));

        versionOptions.CloudBuild.SetVersionVariables = false;
        this.WriteVersionFile(versionOptions);
        buildResult = await this.BuildAsync(this.testProject);
        AssertStandardProperties(versionOptions, buildResult);
        conditionallyExpectedMessage = expectedMessage
            .Replace("{NAME}", "GitBuildVersion")
            .Replace("{VALUE}", buildResult.BuildVersion);
        Assert.Contains(alwaysExpectedMessage, buildResult.LoggedEvents.Select(e => e.Message.TrimEnd()));
        Assert.DoesNotContain(conditionallyExpectedMessage, buildResult.LoggedEvents.Select(e => e.Message.TrimEnd()));
    }
Exemplo n.º 35
0
 public IEnumerable <LayoutPart> GetTemplateClients(int templateId, VersionOptions versionOptions)
 {
     return(_contentManager.Query <LayoutPart, LayoutPartRecord>(versionOptions).Where(x => x.TemplateId == templateId).List().ToArray());
 }
    public async Task BuildNumber_VariousOptions(bool isPublic, VersionOptions.CloudBuildNumberCommitWhere where, VersionOptions.CloudBuildNumberCommitWhen when, [CombinatorialValues(0, 1, 2)] int extraBuildMetadataCount)
    {
        var versionOptions = BuildNumberVersionOptionsBasis;
        versionOptions.CloudBuild.BuildNumber.IncludeCommitId.Where = where;
        versionOptions.CloudBuild.BuildNumber.IncludeCommitId.When = when;
        this.WriteVersionFile(versionOptions);
        this.InitializeSourceControl();

        this.globalProperties["PublicRelease"] = isPublic.ToString();
        for (int i = 0; i < extraBuildMetadataCount; i++)
        {
            this.testProject.AddItem("BuildMetadata", $"A{i}");
        }

        var buildResult = await this.BuildAsync(this.testProject);
        AssertStandardProperties(versionOptions, buildResult);
    }
 private IEnumerable <LocalizationPart> GetDisplayLocalizations(LocalizationPart part, VersionOptions versionOptions)
 {
     return(_localizationService.GetLocalizations(part.ContentItem, versionOptions)
            .Select(c => {
         var localized = c.ContentItem.As <LocalizationPart>();
         if (localized.Culture == null)
         {
             localized.Culture = _cultureManager.GetCultureByName(_cultureManager.GetSiteCulture());
         }
         return c;
     }).ToList());
 }
    private void AssertStandardProperties(VersionOptions versionOptions, BuildResults buildResult, string relativeProjectDirectory = null)
    {
        int versionHeight = this.Repo.GetVersionHeight(relativeProjectDirectory);
        Version idAsVersion = this.Repo.GetIdAsVersion(relativeProjectDirectory);
        string commitIdShort = this.Repo.Head.Commits.First().Id.Sha.Substring(0, 10);
        Version version = this.Repo.GetIdAsVersion(relativeProjectDirectory);
        Version assemblyVersion = GetExpectedAssemblyVersion(versionOptions, version);
        var additionalBuildMetadata = from item in buildResult.BuildResult.ProjectStateAfterBuild.GetItems("BuildMetadata")
                                      select item.EvaluatedInclude;
        var expectedBuildMetadata = $"+g{commitIdShort}";
        if (additionalBuildMetadata.Any())
        {
            expectedBuildMetadata += "." + string.Join(".", additionalBuildMetadata);
        }

        Assert.Equal($"{version}", buildResult.AssemblyFileVersion);
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}{versionOptions.Version.Prerelease}{expectedBuildMetadata}", buildResult.AssemblyInformationalVersion);

        // The assembly version property should always have four integer components to it,
        // per bug https://github.com/AArnott/Nerdbank.GitVersioning/issues/26
        Assert.Equal($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}.{assemblyVersion.Revision}", buildResult.AssemblyVersion);

        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildNumber);
        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildNumberFirstAndSecondComponentsIfApplicable);
        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildNumberFirstComponent);
        Assert.Equal(string.Empty, buildResult.BuildNumberSecondComponent);
        Assert.Equal($"{version}", buildResult.BuildVersion);
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}", buildResult.BuildVersion3Components);
        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildVersionNumberComponent);
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}", buildResult.BuildVersionSimple);
        Assert.Equal(this.Repo.Head.Commits.First().Id.Sha, buildResult.GitCommitId);
        Assert.Equal(commitIdShort, buildResult.GitCommitIdShort);
        Assert.Equal(versionHeight.ToString(), buildResult.GitVersionHeight);
        Assert.Equal($"{version.Major}.{version.Minor}", buildResult.MajorMinorVersion);
        Assert.Equal(versionOptions.Version.Prerelease, buildResult.PrereleaseVersion);
        Assert.Equal(expectedBuildMetadata, buildResult.SemVerBuildSuffix);

        string pkgVersionSuffix = buildResult.PublicRelease
            ? string.Empty
            : $"-g{commitIdShort}";
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}{versionOptions.Version.Prerelease}{pkgVersionSuffix}", buildResult.NuGetPackageVersion);

        var buildNumberOptions = versionOptions.CloudBuild?.BuildNumber ?? new VersionOptions.CloudBuildNumberOptions();
        if (buildNumberOptions.Enabled)
        {
            var commitIdOptions = buildNumberOptions.IncludeCommitId ?? new VersionOptions.CloudBuildNumberCommitIdOptions();
            var buildNumberSemVer = SemanticVersion.Parse(buildResult.CloudBuildNumber);
            bool hasCommitData = commitIdOptions.When == VersionOptions.CloudBuildNumberCommitWhen.Always
                || (commitIdOptions.When == VersionOptions.CloudBuildNumberCommitWhen.NonPublicReleaseOnly && !buildResult.PublicRelease);
            Version expectedVersion = hasCommitData && commitIdOptions.Where == VersionOptions.CloudBuildNumberCommitWhere.FourthVersionComponent
                ? idAsVersion
                : new Version(version.Major, version.Minor, version.Build);
            Assert.Equal(expectedVersion, buildNumberSemVer.Version);
            Assert.Equal(buildResult.PrereleaseVersion, buildNumberSemVer.Prerelease);
            string expectedBuildNumberMetadata = hasCommitData && commitIdOptions.Where == VersionOptions.CloudBuildNumberCommitWhere.BuildMetadata
                ? $"+g{commitIdShort}"
                : string.Empty;
            if (additionalBuildMetadata.Any())
            {
                expectedBuildNumberMetadata = expectedBuildNumberMetadata.Length == 0
                    ? "+" + string.Join(".", additionalBuildMetadata)
                    : expectedBuildNumberMetadata + "." + string.Join(".", additionalBuildMetadata);
            }

            Assert.Equal(expectedBuildNumberMetadata, buildNumberSemVer.BuildMetadata);
        }
        else
        {
            Assert.Equal(string.Empty, buildResult.CloudBuildNumber);
        }
    }
    public async Task GetBuildVersion_In_Git_With_Version_File_In_Root_And_Subdirectory_Works()
    {
        var rootVersionSpec = new VersionOptions { Version = SemanticVersion.Parse("14.1"), AssemblyVersion = new Version(14, 0) };
        var subdirVersionSpec = new VersionOptions { Version = SemanticVersion.Parse("11.0") };
        const string subdirectory = "projdir";

        this.WriteVersionFile(rootVersionSpec);
        this.WriteVersionFile(subdirVersionSpec, subdirectory);
        this.InitializeSourceControl();
        this.AddCommits(this.random.Next(15));
        var buildResult = await this.BuildAsync();
        this.AssertStandardProperties(subdirVersionSpec, buildResult, subdirectory);
    }
    [InlineData(50, -2, true)] // force many build number collisions. generally revision will still make them unique, but it *might* collide on occasion.
    public void GetIdAsVersion_Roundtrip_UnstableOffset(int startingOffset, int offsetStepChange, bool allowCollisions)
    {
        var versionOptions = new VersionOptions
        {
            Version = SemanticVersion.Parse("1.2"),
            AssemblyVersion = null,
            BuildNumberOffset = startingOffset,
        };
        this.WriteVersionFile(versionOptions);

        Commit[] commits = new Commit[16]; // create enough that statistically we'll likely hit interesting bits as MSB and LSB
        Version[] versions = new Version[commits.Length];
        for (int i = 0; i < commits.Length; i += 2)
        {
            versionOptions.BuildNumberOffset += offsetStepChange;
            commits[i] = this.WriteVersionFile(versionOptions);
            versions[i] = commits[i].GetIdAsVersion();

            commits[i + 1] = this.Repo.Commit($"Commit {i + 1}", this.Signer, this.Signer, new CommitOptions { AllowEmptyCommit = true });
            versions[i + 1] = commits[i + 1].GetIdAsVersion();

            this.Logger.WriteLine($"Commit {commits[i].Id.Sha.Substring(0, 8)} as version: {versions[i]}");
            this.Logger.WriteLine($"Commit {commits[i + 1].Id.Sha.Substring(0, 8)} as version: {versions[i + 1]}");

            // Find the commits we just wrote while they are still at the tip of the branch.
            var matchingCommits = this.Repo.GetCommitsFromVersion(versions[i]);
            Assert.Contains(commits[i], matchingCommits);
            matchingCommits = this.Repo.GetCommitsFromVersion(versions[i + 1]);
            Assert.Contains(commits[i + 1], matchingCommits);
        }

        // Find all commits (again) now that history has been written.
        for (int i = 0; i < commits.Length; i++)
        {
            var matchingCommits = this.Repo.GetCommitsFromVersion(versions[i]).ToList();
            Assert.Contains(commits[i], matchingCommits);
            if (!allowCollisions)
            {
                Assert.Equal(1, matchingCommits.Count);
            }
        }
    }
    public async Task PublicRelease_RegEx_Unsatisfied()
    {
        var versionOptions = new VersionOptions
        {
            Version = SemanticVersion.Parse("1.0"),
            PublicReleaseRefSpec = new string[] { "^refs/heads/release$" },
        };
        this.WriteVersionFile(versionOptions);
        this.InitializeSourceControl();

        // Just build "master", which doesn't conform to the regex.
        var buildResult = await this.BuildAsync();
        Assert.False(buildResult.PublicRelease);
        AssertStandardProperties(versionOptions, buildResult);
    }
        public int?GetHomePageId(VersionOptions version = null)
        {
            var homePage = GetHomePage(version);

            return(homePage != null ? homePage.Id : default(int?));
        }
 private void AssertPathHasVersion(string committish, string absolutePath, VersionOptions expected)
 {
     var actual = this.GetVersionOptions(absolutePath, committish);
     Assert.Equal(expected, this.GetVersionOptions(absolutePath, committish));
 }
 public async Task GetBuildVersion_CustomBuildNumberOffset()
 {
     this.WriteVersionFile("14.0");
     this.InitializeSourceControl();
     var versionOptions = new VersionOptions
     {
         Version = new SemanticVersion(new Version(14, 1)),
         BuildNumberOffset = 5,
     };
     this.WriteVersionFile(versionOptions);
     var buildResult = await this.BuildAsync();
     this.AssertStandardProperties(versionOptions, buildResult);
 }
        public bool IsHomePage(IContent content, VersionOptions homePageVersion = null)
        {
            var homePageId = GetHomePageId(homePageVersion);

            return(content.Id == homePageId);
        }
    public async Task PublicRelease_RegEx_SatisfiedByCI(IReadOnlyDictionary<string, string> serverProperties)
    {
        var versionOptions = new VersionOptions
        {
            Version = SemanticVersion.Parse("1.0"),
            PublicReleaseRefSpec = new string[] { "^refs/heads/release$" },
        };
        this.WriteVersionFile(versionOptions);
        this.InitializeSourceControl();

        // Don't actually switch the checked out branch in git. CI environment variables
        // should take precedence over actual git configuration. (Why? because these variables may
        // retain information about which tag was checked out on a detached head).
        foreach (var property in serverProperties)
        {
            this.globalProperties[property.Key] = property.Value;
        }

        var buildResult = await this.BuildAsync();
        Assert.True(buildResult.PublicRelease);
        AssertStandardProperties(versionOptions, buildResult);
    }
Exemplo n.º 47
0
 /// <summary>
 /// Queries the database for the given container and returns a list of the container contents with the specified Part.
 /// </summary>
 public static IEnumerable <TPart> GetContainerContentsOfType <TPart, TRecord>(this IContentManager contentManager, int containerId, VersionOptions versionOptions = null)
     where TPart : ContentPart <TRecord>
     where TRecord : ContentPartRecord
 {
     return(contentManager
            .Query <TPart, TRecord>(versionOptions ?? VersionOptions.Published)
            .Join <CommonPartRecord>()
            .Where(x => x.Container != null && x.Container.Id == containerId)
            .Join <ContainablePartRecord>()
            .OrderByDescending(x => x.Position)
            .List());
 }
    private void AssertStandardProperties(VersionOptions versionOptions, BuildResults buildResult, string relativeProjectDirectory = null)
    {
        int versionHeight = this.Repo.GetVersionHeight(relativeProjectDirectory);
        Version idAsVersion = this.Repo.GetIdAsVersion(relativeProjectDirectory);
        string commitIdShort = this.Repo.Head.Commits.First().Id.Sha.Substring(0, 10);
        Version version = this.Repo.GetIdAsVersion(relativeProjectDirectory);
        Version assemblyVersion = (versionOptions.AssemblyVersion ?? versionOptions.Version.Version).EnsureNonNegativeComponents();
        Assert.Equal($"{version}", buildResult.AssemblyFileVersion);
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}{versionOptions.Version.Prerelease}+g{commitIdShort}", buildResult.AssemblyInformationalVersion);

        // The assembly version property should always have four integer components to it,
        // per bug https://github.com/AArnott/Nerdbank.GitVersioning/issues/26
        Assert.Equal($"{assemblyVersion.Major}.{assemblyVersion.Minor}.{assemblyVersion.Build}.{assemblyVersion.Revision}", buildResult.AssemblyVersion);

        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildNumber);
        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildNumberFirstAndSecondComponentsIfApplicable);
        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildNumberFirstComponent);
        Assert.Equal(string.Empty, buildResult.BuildNumberSecondComponent);
        Assert.Equal($"{version}", buildResult.BuildVersion);
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}", buildResult.BuildVersion3Components);
        Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildVersionNumberComponent);
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}", buildResult.BuildVersionSimple);
        Assert.Equal(this.Repo.Head.Commits.First().Id.Sha, buildResult.GitCommitId);
        Assert.Equal(commitIdShort, buildResult.GitCommitIdShort);
        Assert.Equal(versionHeight.ToString(), buildResult.GitVersionHeight);
        Assert.Equal($"{version.Major}.{version.Minor}", buildResult.MajorMinorVersion);
        Assert.Equal(versionOptions.Version.Prerelease, buildResult.PrereleaseVersion);
        Assert.Equal($"+g{commitIdShort}", buildResult.SemVerBuildSuffix);

        string pkgVersionSuffix = buildResult.PublicRelease
            ? string.Empty
            : $"-g{commitIdShort}";
        Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}{versionOptions.Version.Prerelease}{pkgVersionSuffix}", buildResult.NuGetPackageVersion);
    }
Exemplo n.º 49
0
    protected Commit WriteVersionFile(string version = "1.2", string prerelease = "", string relativeDirectory = null)
    {
        var versionData = VersionOptions.FromVersion(new System.Version(version), prerelease);

        return(this.WriteVersionFile(versionData, relativeDirectory));
    }
    public void GetVersion_String_FindsNearestFileInAncestorDirectories_WithAssemblyVersion()
    {
        // Construct a repo where versions are defined like this:
        /*   root <- 14.0
                a             (inherits 14.0)
                    b <- 11.0
                         c    (inherits 11.0)
        */
        var rootVersionSpec = new VersionOptions
        {
            Version = SemanticVersion.Parse("14.1"),
            AssemblyVersion = new VersionOptions.AssemblyVersionOptions(new Version(14, 0)),
        };
        var subdirVersionSpec = new VersionOptions { Version = SemanticVersion.Parse("11.0") };

        VersionFile.SetVersion(this.RepoPath, rootVersionSpec);
        string subDirA = Path.Combine(this.RepoPath, "a");
        string subDirAB = Path.Combine(subDirA, "b");
        string subDirABC = Path.Combine(subDirAB, "c");
        Directory.CreateDirectory(subDirABC);
        VersionFile.SetVersion(subDirAB, subdirVersionSpec);
        this.InitializeSourceControl();
        var commit = this.Repo.Head.Commits.First();

        AssertPathHasVersion(commit, subDirABC, subdirVersionSpec);
        AssertPathHasVersion(commit, subDirAB, subdirVersionSpec);
        AssertPathHasVersion(commit, subDirA, rootVersionSpec);
        AssertPathHasVersion(commit, this.RepoPath, rootVersionSpec);
    }
Exemplo n.º 51
0
        public async Task <IActionResult> Handle(string workflowDefinitionId, VersionOptions versionOptions, CancellationToken cancellationToken = default)
        {
            var workflowDefinition = await _workflowDefinitionStore.FindAsync(new WorkflowDefinitionIdSpecification(workflowDefinitionId, versionOptions), cancellationToken);

            return(workflowDefinition == null?NotFound() : Json(workflowDefinition, SerializationHelper.GetSettingsForWorkflowDefinition()));
        }
Exemplo n.º 52
0
        public override async ValueTask <IWorkflowBlueprint?> FindByTagAsync(string tag, VersionOptions versionOptions, string?tenantId = default, CancellationToken cancellationToken = default)
        {
            var workflowDefinition = await _workflowDefinitionStore.FindAsync(new WorkflowDefinitionTagSpecification(tag, versionOptions), cancellationToken);

            return(workflowDefinition == null ? null : await TryMaterializeBlueprintAsync(workflowDefinition, cancellationToken));
        }
Exemplo n.º 53
0
        private IEnumerable <TermPart> GetAppliedTerms(ContentPart part, TaxonomyField field = null, VersionOptions versionOptions = null)
        {
            string fieldName = field != null ? field.Name : string.Empty;

            return(_taxonomyService.GetTermsForContentItem(part.ContentItem.Id, fieldName, versionOptions ?? VersionOptions.Published).Distinct(new TermPartComparer()));
        }
Exemplo n.º 54
0
        /// <summary>
        /// Writes the version.txt file to a directory within a repo with the specified version information.
        /// </summary>
        /// <param name="projectDirectory">
        /// The path to the directory in which to write the version.txt file.
        /// The file's impact will be all descendent projects and directories from this specified directory,
        /// except where any of those directories have their own version.txt file.
        /// </param>
        /// <param name="version">The version information to write to the file.</param>
        /// <returns>The path to the file written.</returns>
        public static string SetVersion(string projectDirectory, VersionOptions version)
        {
            Requires.NotNullOrEmpty(projectDirectory, nameof(projectDirectory));
            Requires.NotNull(version, nameof(version));
            Requires.Argument(version.Version != null, nameof(version), $"{nameof(VersionOptions.Version)} must be set.");

            Directory.CreateDirectory(projectDirectory);

            string versionTxtPath = Path.Combine(projectDirectory, TxtFileName);
            if (File.Exists(versionTxtPath))
            {
                if (version.IsDefaultVersionTheOnlyPropertySet)
                {
                    File.WriteAllLines(
                        versionTxtPath,
                        new[] { version.Version.Version.ToString(), version.Version.Prerelease });
                    return versionTxtPath;
                }
                else
                {
                    // The file must be upgraded to use the more descriptive JSON format.
                    File.Delete(versionTxtPath);
                }
            }

            string versionJsonPath = Path.Combine(projectDirectory, JsonFileName);
            var jsonContent = JsonConvert.SerializeObject(version, JsonSettings);
            File.WriteAllText(versionJsonPath, jsonContent);
            return versionJsonPath;
        }
Exemplo n.º 55
0
 public void Create(ContentItem contentItem, VersionOptions options)
 {
     _decoratedService.Create(contentItem, options);
 }
Exemplo n.º 56
0
        /// <summary>
        /// Gets the version options from HEAD and the working copy (if applicable),
        /// and tests their equality.
        /// </summary>
        /// <param name="repo">The repo to scan for version info.</param>
        /// <param name="repoRelativeProjectDirectory">The path to the directory of the project whose version is being queried, relative to the repo root.</param>
        /// <param name="committedVersion">Receives the version options from the HEAD commit.</param>
        /// <param name="workingCopyVersion">Receives the version options from the working copy, when applicable.</param>
        /// <returns><c>true</c> if <paramref name="committedVersion"/> and <paramref name="workingCopyVersion"/> are not equal.</returns>
        private static bool IsVersionFileChangedInWorkingCopy(Repository repo, string repoRelativeProjectDirectory, out VersionOptions committedVersion, out VersionOptions workingCopyVersion)
        {
            Requires.NotNull(repo, nameof(repo));
            Commit headCommit = repo.Head.Commits.FirstOrDefault();
            committedVersion = VersionFile.GetVersion(headCommit, repoRelativeProjectDirectory);

            if (!repo.Info.IsBare)
            {
                string fullDirectory = Path.Combine(repo.Info.WorkingDirectory, repoRelativeProjectDirectory ?? string.Empty);
                workingCopyVersion = VersionFile.GetVersion(fullDirectory);
                return !EqualityComparer<VersionOptions>.Default.Equals(workingCopyVersion, committedVersion);
            }

            workingCopyVersion = null;
            return false;
        }
 public ObjectivePart Get(int id, VersionOptions versionOptions)
 {
     return(_contentManager.Get <ObjectivePart>(id, versionOptions));
 }