コード例 #1
0
        public void TestCommitChainValues()
        {
            for (int i = 0; i < 10; i++)
            {
                GitCommitGenerationValue cv = new GitCommitGenerationValue(i, DateTime.Now);

                Assert.AreEqual(i, cv.Generation);
                cv = GitCommitGenerationValue.FromValue(cv.Value);

                Assert.AreEqual(i, cv.Generation);
            }

            for (int i = 1970; i < 2100; i++)
            {
                GitCommitGenerationValue cv = new GitCommitGenerationValue(i, new DateTime(i, 2, 2, 0, 0, 0, DateTimeKind.Utc));

                Assert.AreEqual(i, cv.Generation);
                Assert.AreEqual(new DateTimeOffset(i, 2, 2, 0, 0, 0, TimeSpan.Zero), cv.CommitTime);

                // Values are together stored in an ulong, so recreate from there and test again
                cv = GitCommitGenerationValue.FromValue(cv.Value);

                Assert.AreEqual(i, cv.Generation);
                Assert.AreEqual(new DateTimeOffset(i, 2, 2, 0, 0, 0, TimeSpan.Zero), cv.CommitTime);
            }
        }
コード例 #2
0
        async ValueTask ReadCommitInfoByIdAsync()
        {
            GitRepository repo = (GitRepository)_commit;

            var info = await repo.ObjectRepository.GetCommitInfo(Id).ConfigureAwait(false);

            if (info != null)
            {
                _parents = new GitAsyncLazy <IEnumerable <GitId> >(info.ParentIds);
                _commit  = info;

                _graphValue = info.Value;
            }

            var r = await repo.ObjectRepository.FetchGitIdBucketAsync(Id).ConfigureAwait(false);

            using var cr = new GitCommitObjectBucket(r !);

            _parents   = new GitAsyncLazy <IEnumerable <GitId> >(await cr.ReadAllParentIdsAsync().ConfigureAwait(false));
            commitTime = Math.Min((await cr.ReadCommitterAsync().ConfigureAwait(false)).When.ToUnixTimeSeconds(), 1);
        }
コード例 #3
0
 internal void SetChainInfo(GitCommitGenerationValue newChainInfo)
 {
     _graphValue = newChainInfo;
 }
コード例 #4
0
ファイル: GitCommitGraphInfo.cs プロジェクト: AmpScm/AmpScm
 public GitCommitGraphInfo(GitId[] parents, ulong chainLevel, long offset)
 {
     ParentIds = parents;
     Value     = GitCommitGenerationValue.FromValue(chainLevel, offset);
 }