コード例 #1
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        // http://stackoverflow.com/questions/3407575/retrieving-oldest-commit-with-jgit
        public virtual void GetOldestCommit(string path)
        {
            NGit.Revwalk.RevCommit c          = null;
            NGit.Api.Git           repository = NGit.Api.Git.Open(path);


            try
            {
                NGit.Revwalk.RevWalk rw = new NGit.Revwalk.RevWalk(repository.GetRepository());

                NGit.AnyObjectId       headid = repository.GetRepository().Resolve(NGit.Constants.HEAD);
                NGit.Revwalk.RevCommit root   = rw.ParseCommit(headid);

                string msg1 = root.GetFullMessage();


                rw.Sort(NGit.Revwalk.RevSort.REVERSE);

                rw.MarkStart(root);
                c = rw.Next();
                // repository.GetRepository().
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            string msg2 = c.GetFullMessage();

            // Get author
            NGit.PersonIdent    authorIdent    = c.GetAuthorIdent();
            System.DateTime     authorDate     = authorIdent.GetWhen();
            System.TimeZoneInfo authorTimeZone = authorIdent.GetTimeZone();

            NGit.PersonIdent committerIdent = c.GetCommitterIdent();
            // http://stackoverflow.com/questions/12608610/how-do-you-get-the-author-date-and-commit-date-from-a-jgit-revcommit

            System.Console.WriteLine(authorIdent);
            System.Console.WriteLine(authorDate);
            System.Console.WriteLine(authorTimeZone);
            System.Console.WriteLine(committerIdent);

            CloseRepository(repository);
        }
コード例 #2
0
ファイル: Git.cs プロジェクト: ststeiger/NancyHub
        public virtual System.DateTime GetOldestCommitDate(string path)
        {
            System.DateTime retVal = default(System.DateTime);

            NGit.Revwalk.RevCommit c          = null;
            NGit.Api.Git           repository = NGit.Api.Git.Open(path);


            try
            {
                NGit.Revwalk.RevWalk rw = new NGit.Revwalk.RevWalk(repository.GetRepository());

                NGit.AnyObjectId       headid = repository.GetRepository().Resolve(NGit.Constants.HEAD);
                NGit.Revwalk.RevCommit root   = rw.ParseCommit(headid);

                string msg1 = root.GetFullMessage();


                rw.Sort(NGit.Revwalk.RevSort.REVERSE);

                rw.MarkStart(root);
                c = rw.Next();
                // repository.GetRepository().
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

            string msg2 = c.GetFullMessage();

            // Get author
            NGit.PersonIdent authorIdent = c.GetAuthorIdent();
            System.DateTime  authorDate  = authorIdent.GetWhen();

            retVal = authorDate.ToUniversalTime();

            CloseRepository(repository);

            return(retVal);
        }