Ejemplo n.º 1
0
        } // End Function GetRemoteBranchId

        // http://stackoverflow.com/questions/3407575/retrieving-oldest-commit-with-jgit
        public virtual System.DateTime GetLastCommitDate(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);
                c = rw.ParseCommit(headid);

                // repository.GetRepository().
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }

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

            retVal = authorDate.ToUniversalTime();

            CloseRepository(repository);

            return(retVal);
        }
Ejemplo n.º 2
0
        // 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);
        }