Example #1
0
    public static ReleaseDate Execute(IRepository repo, string commitSha, int calculatedPatch)
    {
        var c = repo.Lookup<Commit>(commitSha);
        Debug.Assert(c != null);

        var rd = new ReleaseDate
                 {
                     OriginalDate = c.When(),
                     OriginalCommitSha = c.Sha,
                     Date = c.When(),
                     CommitSha = c.Sha,
                 };

        if (GitVersionFinder.ShouldGitHubFlowVersioningSchemeApply(repo))
        {
            return rd;
        }

        if (calculatedPatch == 0)
        {
            return rd;
        }

        var vp = new VersionOnMasterFinder().FindLatestStableTaggedCommitReachableFrom(repo, c);
        var latestStable = repo.Lookup<Commit>(vp.CommitSha);
        Debug.Assert(latestStable != null);

        rd.OriginalDate = latestStable.When();
        rd.OriginalCommitSha = vp.CommitSha;
        return rd;
    }
Example #2
0
        internal DirectReference(string canonicalName, IRepository repo, ObjectId targetId)
            : base(repo, canonicalName, targetId.Sha)
        {
            targetBuilder = new Lazy<GitObject>(() =>
            {
                if (repo == null)
                {
                    throw new InvalidOperationException("Target requires a local repository");
                }

                return repo.Lookup(targetId);
            });
        }
        private static void AssertNormalization(IRepository repo, string filename, bool shouldHaveBeenNormalized, string expectedSha)
        {
            var sb = new StringBuilder();
            sb.Append("I'm going to be dynamically processed\r\n");
            sb.Append("And my line endings...\r\n");
            sb.Append("...are going to be\n");
            sb.Append("normalized!\r\n");

            Touch(repo.Info.WorkingDirectory, filename, sb.ToString());

            repo.Index.Stage(filename);

            IndexEntry entry = repo.Index[filename];
            Assert.NotNull(entry);

            Assert.Equal(expectedSha, entry.Id.Sha);

            var blob = repo.Lookup<Blob>(entry.Id);
            Assert.NotNull(blob);

            Assert.Equal(!shouldHaveBeenNormalized, blob.GetContentText().Contains("\r"));
        }
 internal DirectReference(string canonicalName, IRepository repo, ObjectId targetId)
     : base(canonicalName, targetId.Sha)
 {
     targetBuilder = new Lazy<GitObject>(() => repo.Lookup(targetId));
 }