~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ngit/NGit.Test/NGit/ReflogResolveTest.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
 
71
71
                /// <exception cref="System.Exception"></exception>
72
72
                [NUnit.Framework.Test]
 
73
                public virtual void ResolveUnnamedCurrentBranchCommits()
 
74
                {
 
75
                        Git git = new Git(db);
 
76
                        WriteTrashFile("file.txt", "content");
 
77
                        git.Add().AddFilepattern("file.txt").Call();
 
78
                        RevCommit c1 = git.Commit().SetMessage("create file").Call();
 
79
                        WriteTrashFile("file.txt", "content2");
 
80
                        git.Add().AddFilepattern("file.txt").Call();
 
81
                        RevCommit c2 = git.Commit().SetMessage("edit file").Call();
 
82
                        NUnit.Framework.Assert.AreEqual(c2, db.Resolve("master@{0}"));
 
83
                        NUnit.Framework.Assert.AreEqual(c1, db.Resolve("master@{1}"));
 
84
                        git.Checkout().SetCreateBranch(true).SetName("newbranch").SetStartPoint(c1).Call(
 
85
                                );
 
86
                        // same as current branch, e.g. master
 
87
                        NUnit.Framework.Assert.AreEqual(c1, db.Resolve("@{0}"));
 
88
                        try
 
89
                        {
 
90
                                NUnit.Framework.Assert.AreEqual(c1, db.Resolve("@{1}"));
 
91
                                NUnit.Framework.Assert.Fail();
 
92
                        }
 
93
                        catch (RevisionSyntaxException e)
 
94
                        {
 
95
                                // Looking at wrong ref, e.g HEAD
 
96
                                NUnit.Framework.Assert.IsNotNull(e);
 
97
                        }
 
98
                        // detached head, read HEAD reflog
 
99
                        git.Checkout().SetName(c2.GetName()).Call();
 
100
                        NUnit.Framework.Assert.AreEqual(c2, db.Resolve("@{0}"));
 
101
                        NUnit.Framework.Assert.AreEqual(c1, db.Resolve("@{1}"));
 
102
                        NUnit.Framework.Assert.AreEqual(c2, db.Resolve("@{2}"));
 
103
                }
 
104
 
 
105
                /// <exception cref="System.Exception"></exception>
 
106
                [NUnit.Framework.Test]
73
107
                public virtual void ResolveReflogParent()
74
108
                {
75
109
                        Git git = new Git(db);
95
129
 
96
130
                /// <exception cref="System.Exception"></exception>
97
131
                [NUnit.Framework.Test]
98
 
                public virtual void ResolveNegativeEntryNumber()
 
132
                public virtual void ResolvePreviousBranch()
99
133
                {
100
134
                        Git git = new Git(db);
101
135
                        WriteTrashFile("file.txt", "content");
102
136
                        git.Add().AddFilepattern("file.txt").Call();
103
 
                        git.Commit().SetMessage("create file").Call();
 
137
                        RevCommit c1 = git.Commit().SetMessage("create file").Call();
 
138
                        WriteTrashFile("file.txt", "content2");
 
139
                        git.Add().AddFilepattern("file.txt").Call();
 
140
                        RevCommit c2 = git.Commit().SetMessage("edit file").Call();
 
141
                        git.Checkout().SetCreateBranch(true).SetName("newbranch").SetStartPoint(c1).Call(
 
142
                                );
 
143
                        git.Checkout().SetName(c1.GetName()).Call();
 
144
                        git.Checkout().SetName("master").Call();
 
145
                        NUnit.Framework.Assert.AreEqual(c1.GetName(), db.Simplify("@{-1}"));
 
146
                        NUnit.Framework.Assert.AreEqual("newbranch", db.Simplify("@{-2}"));
 
147
                        NUnit.Framework.Assert.AreEqual("master", db.Simplify("@{-3}"));
 
148
                        // chained expression
104
149
                        try
105
150
                        {
106
 
                                db.Resolve("master@{-12}");
107
 
                                NUnit.Framework.Assert.Fail("Exception not thrown");
 
151
                                // Cannot refer to reflog of detached head
 
152
                                db.Resolve("@{-1}@{0}");
 
153
                                NUnit.Framework.Assert.Fail();
108
154
                        }
109
 
                        catch (RevisionSyntaxException e)
 
155
                        catch (RevisionSyntaxException)
110
156
                        {
111
 
                                NUnit.Framework.Assert.IsNotNull(e);
112
157
                        }
 
158
                        // good
 
159
                        NUnit.Framework.Assert.AreEqual(c1.GetName(), db.Resolve("@{-2}@{0}").GetName());
 
160
                        NUnit.Framework.Assert.AreEqual(c2.GetName(), db.Resolve("@{-3}@{0}").GetName());
113
161
                }
114
162
 
115
163
                /// <exception cref="System.Exception"></exception>