コード例 #1
0
        public virtual void TestParse_OnlyLFMessage()
        {
            RevCommit c = Create("\n");

            NUnit.Framework.Assert.AreEqual("\n", c.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(string.Empty, c.GetShortMessage());
        }
コード例 #2
0
        public virtual void TestParse_explicit_bad_encoded2()
        {
            ByteArrayOutputStream b = new ByteArrayOutputStream();

            b.Write(Sharpen.Runtime.GetBytesForString("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
                                                      , "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n"
                                                      , "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("committer C O. Miter <*****@*****.**> 1218123390 -0500\n"
                                                      , "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("encoding ISO-8859-1\n", "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("\n", "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("\u304d\u308c\u3044\n", "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("\n", "UTF-8"));
            b.Write(Sharpen.Runtime.GetBytesForString("Hi\n", "UTF-8"));
            RevCommit c;

            c = new RevCommit(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
            // bogus id
            c.ParseCanonical(new RevWalk(db), b.ToByteArray());
            NUnit.Framework.Assert.AreEqual("ISO-8859-1", c.Encoding.Name());
            NUnit.Framework.Assert.AreEqual("F\u00f6r fattare", c.GetAuthorIdent().GetName());
            NUnit.Framework.Assert.AreEqual("\u304d\u308c\u3044", c.GetShortMessage());
            NUnit.Framework.Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.GetFullMessage());
        }
コード例 #3
0
        public virtual void TestParse_ShortLineOnlyNoLF()
        {
            string    shortMsg = "This is a short message.";
            RevCommit c        = Create(shortMsg);

            NUnit.Framework.Assert.AreEqual(shortMsg, c.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(shortMsg, c.GetShortMessage());
        }
コード例 #4
0
        public virtual void TestParse_NoMessage()
        {
            string    msg = string.Empty;
            RevCommit c   = Create(msg);

            NUnit.Framework.Assert.AreEqual(msg, c.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(msg, c.GetShortMessage());
        }
コード例 #5
0
        public virtual void TestParse_ShortLineOnlyEmbeddedAndEndingLF()
        {
            string    fullMsg  = "This is a\nshort message.\n";
            string    shortMsg = "This is a short message.";
            RevCommit c        = Create(fullMsg);

            NUnit.Framework.Assert.AreEqual(fullMsg, c.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(shortMsg, c.GetShortMessage());
        }
コード例 #6
0
        public virtual void TestParse_GitStyleMessage()
        {
            string    shortMsg = "This fixes a bug.";
            string    body     = "We do it with magic and pixie dust and stuff.\n" + "\n" + "Signed-off-by: A U. Thor <*****@*****.**>\n";
            string    fullMsg  = shortMsg + "\n" + "\n" + body;
            RevCommit c        = Create(fullMsg);

            NUnit.Framework.Assert.AreEqual(fullMsg, c.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(shortMsg, c.GetShortMessage());
        }
コード例 #7
0
        public virtual void TestParse_WeirdHeaderOnlyCommit()
        {
            StringBuilder b = new StringBuilder();

            b.Append("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n");
            b.Append("author A U. Thor <*****@*****.**> 1218123387 +0700\n");
            b.Append("committer C O. Miter <*****@*****.**> 1218123390 -0500\n");
            RevCommit c;

            c = new RevCommit(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
            c.ParseCanonical(new RevWalk(db), Sharpen.Runtime.GetBytesForString(b.ToString(),
                                                                                "UTF-8"));
            NUnit.Framework.Assert.AreEqual(string.Empty, c.GetFullMessage());
            NUnit.Framework.Assert.AreEqual(string.Empty, c.GetShortMessage());
        }
コード例 #8
0
        public virtual void TestParse_PublicParseMethod()
        {
            ObjectInserter.Formatter fmt = new ObjectInserter.Formatter();
            NGit.CommitBuilder       src = new NGit.CommitBuilder();
            src.TreeId    = fmt.IdFor(Constants.OBJ_TREE, new byte[] {  });
            src.Author    = author;
            src.Committer = committer;
            src.Message   = "Test commit\n\nThis is a test.\n";
            RevCommit p = RevCommit.Parse(src.Build());

            NUnit.Framework.Assert.AreEqual(src.TreeId, p.Tree);
            NUnit.Framework.Assert.AreEqual(0, p.ParentCount);
            NUnit.Framework.Assert.AreEqual(author, p.GetAuthorIdent());
            NUnit.Framework.Assert.AreEqual(committer, p.GetCommitterIdent());
            NUnit.Framework.Assert.AreEqual("Test commit", p.GetShortMessage());
            NUnit.Framework.Assert.AreEqual(src.Message, p.GetFullMessage());
        }
コード例 #9
0
ファイル: Repository.cs プロジェクト: dineshkummarc/Ometh
 private static Commit ToCommit(RevCommit commit, Repository repository)
 {
     return new Commit
     (
         repository,
         commit.Name,
         commit.GetShortMessage(),
         ToPerson(commit.GetAuthorIdent()),
         ToPerson(commit.GetCommitterIdent()),
         commit.GetCommitterIdent().GetWhen(),
         commit.Parents.Select(p => p.Name)
     );
 }
コード例 #10
0
 public virtual void TestParse_explicit_bad_encoded()
 {
     ByteArrayOutputStream b = new ByteArrayOutputStream();
     b.Write(Sharpen.Runtime.GetBytesForString("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n"
         , "UTF-8"));
     b.Write(Sharpen.Runtime.GetBytesForString("author F\u00f6r fattare <*****@*****.**> 1218123387 +0700\n"
         , "ISO-8859-1"));
     b.Write(Sharpen.Runtime.GetBytesForString("committer C O. Miter <*****@*****.**> 1218123390 -0500\n"
         , "UTF-8"));
     b.Write(Sharpen.Runtime.GetBytesForString("encoding EUC-JP\n", "UTF-8"));
     b.Write(Sharpen.Runtime.GetBytesForString("\n", "UTF-8"));
     b.Write(Sharpen.Runtime.GetBytesForString("\u304d\u308c\u3044\n", "UTF-8"));
     b.Write(Sharpen.Runtime.GetBytesForString("\n", "UTF-8"));
     b.Write(Sharpen.Runtime.GetBytesForString("Hi\n", "UTF-8"));
     RevCommit c;
     c = new RevCommit(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
     // bogus id
     c.ParseCanonical(new RevWalk(db), b.ToByteArray());
     NUnit.Framework.Assert.AreEqual("Japanese (EUC)", c.Encoding.EncodingName);
     NUnit.Framework.Assert.AreEqual("F\u00f6r fattare", c.GetAuthorIdent().GetName());
     NUnit.Framework.Assert.AreEqual("\u304d\u308c\u3044", c.GetShortMessage());
     NUnit.Framework.Assert.AreEqual("\u304d\u308c\u3044\n\nHi\n", c.GetFullMessage());
 }
コード例 #11
0
 public virtual void TestParse_WeirdHeaderOnlyCommit()
 {
     StringBuilder b = new StringBuilder();
     b.Append("tree 9788669ad918b6fcce64af8882fc9a81cb6aba67\n");
     b.Append("author A U. Thor <*****@*****.**> 1218123387 +0700\n");
     b.Append("committer C O. Miter <*****@*****.**> 1218123390 -0500\n");
     RevCommit c;
     c = new RevCommit(Id("9473095c4cb2f12aefe1db8a355fe3fafba42f67"));
     c.ParseCanonical(new RevWalk(db), Sharpen.Runtime.GetBytesForString(b.ToString(),
         "UTF-8"));
     NUnit.Framework.Assert.AreEqual(string.Empty, c.GetFullMessage());
     NUnit.Framework.Assert.AreEqual(string.Empty, c.GetShortMessage());
 }
コード例 #12
0
		public bool Rebase ()
		{
			NGit.Api.Git git = new NGit.Api.Git (repo);
			
			if (aborted)
				return false;
			
			if (starting) {
				ObjectId headId = repo.Resolve (Constants.HEAD + "^{commit}");
				RevCommit headCommit = rw.ParseCommit (headId);
				oldHead = headCommit;
				ObjectId upstreamId = repo.Resolve (upstreamRef);
				RevCommit upstreamCommit = rw.ParseCommit (upstreamId);
				
				oldHead = headCommit;
				lastGoodHead = upstreamId;
				commitChain = new List<RevCommit> ();
			
				LogCommand cmd = new NGit.Api.Git(repo).Log().AddRange(upstreamId, headCommit);
				foreach (RevCommit commit in cmd.Call())
					commitChain.Add(commit);
				
				commitChain.Reverse ();
				currentMergeIndex = 0;
				
				// Checkout the upstream commit
				// Reset head to upstream
				GitUtil.HardReset (repo, upstreamRef);
				
				string rebaseDir = Path.Combine (repo.Directory, "rebase-apply");
				if (!Directory.Exists (rebaseDir))
					Directory.CreateDirectory (rebaseDir);
				
				string rebasingFile = Path.Combine (rebaseDir, "rebasing");
				if (!File.Exists (rebasingFile))
					File.WriteAllBytes (rebasingFile, new byte[0]);
				
				starting = false;
				monitor.BeginTask ("Applying local commits", commitChain.Count);
			}
			else {
				// Conflicts resolved. Continue.
				NGit.Api.AddCommand cmd = git.Add ();
				var conflicts = LastMergeResult.GetConflicts ();
				foreach (string conflictFile in conflicts.Keys) {
					cmd.AddFilepattern (conflictFile);
				}
				cmd.Call ();
				NGit.Api.CommitCommand commit = git.Commit ();
				commit.SetMessage (currentMergeCommit.GetFullMessage ());
				commit.SetAuthor (currentMergeCommit.GetAuthorIdent ());
				commit.SetCommitter (currentMergeCommit.GetCommitterIdent ());
				commit.Call();
			}
			
			// Merge commit by commit until the current head
			
			while (currentMergeIndex < commitChain.Count) {
				currentMergeCommit = commitChain[currentMergeIndex++];
				mergeResult = GitUtil.CherryPick (repo, currentMergeCommit);
				monitor.Log.WriteLine ("Applied '{0}'", currentMergeCommit.GetShortMessage ());
				monitor.Step (1);
				if (mergeResult.GetMergeStatus () == MergeStatus.CONFLICTING || mergeResult.GetMergeStatus () == MergeStatus.FAILED)
					return false;
				lastGoodHead = mergeResult.GetNewHead ();
			}
			
			monitor.EndTask ();
			CleanRebaseFile ();
			return true;
		}