| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001426849e449-dbf25c28-1247-49f8-b659-d961557a3ea4-000000@email.amazonses.com> |
Branch: refs/heads/vcsTests
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/9ade8bf0ff0f...080a13ce0b85
Commit: 080a13ce0b85d4728d3f27ff772040d9aa75e5aa
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-17 22:56:17 GMT
URL: https://github.com/mono/monodevelop/commit/080a13ce0b85d4728d3f27ff772040d9aa75e5aa
[VersionControl] Implemented backend specific tests
Include a fixup for GetPushDiff.
Changed paths:
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseRepositoryTests.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/BaseSvnRepositoryTests.cs
M main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/RepositoryTests.cs
M main/src/addins/VersionControl/Subversion.Win32.Tests/RepositoryTests.cs
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseGitRepositoryTests.cs
===================================================================
@@ -32,14 +32,14 @@
using NGit.Api;
using NUnit.Framework;
using System.IO;
-using System;
using NGit.Storage.File;
using NGit.Revwalk;
+using System.Linq;
namespace MonoDevelop.VersionControl.Git.Tests
{
[TestFixture]
- public class BaseGitUtilsTest : BaseRepoUtilsTest
+ sealed class BaseGitUtilsTest : BaseRepoUtilsTest
{
[SetUp]
public override void Setup ()
@@ -161,6 +161,184 @@ protected override void BlameExtraInternals (Annotation [] annotations)
Assert.IsTrue (annotations [2].HasDate);
}
+ [Test]
+ public void TestGitStash ()
+ {
+ var repo2 = (GitRepository)Repo;
+ AddFile ("file2", "nothing", true, true);
+ AddFile ("file1", "text", true, false);
+ repo2.GetStashes ().Create (null);
+ Assert.IsTrue (!File.Exists (RootCheckout + "file1"), "Stash creation failure");
+ repo2.GetStashes ().Pop (null);
+
+ VersionInfo vi = repo2.GetVersionInfo (RootCheckout + "file1", VersionInfoQueryFlags.IgnoreCache);
+ Assert.AreEqual (VersionStatus.ScheduledAdd, vi.Status & VersionStatus.ScheduledAdd, "Stash pop failure");
+ }
+
+ [Test]
+ public void TestGitBranchCreation ()
+ {
+ var repo2 = (GitRepository)Repo;
+
+ AddFile ("file1", "text", true, true);
+ repo2.CreateBranch ("branch1", null);
+
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "branch1");
+ Assert.AreEqual ("branch1", repo2.GetCurrentBranch ());
+ Assert.IsTrue (File.Exists (RootCheckout + "file1"), "Branch not inheriting from current.");
+
+ AddFile ("file2", "text", true, false);
+ repo2.CreateBranch ("branch2", null);
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "branch2");
+ Assert.IsTrue (!File.Exists (RootCheckout + "file2"), "Uncommitted changes were not stashed");
+ repo2.GetStashes ().Pop (new NullProgressMonitor ());
+
+ Assert.IsTrue (File.Exists (RootCheckout + "file2"), "Uncommitted changes were not stashed correctly");
+
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "master");
+ repo2.RemoveBranch ("branch1");
+ Assert.IsFalse (repo2.GetBranches ().Any (b => b.Name == "branch1"), "Failed to delete branch");
+
+ repo2.RenameBranch ("branch2", "branch3");
+ Assert.IsTrue (repo2.GetBranches ().Any (b => b.Name == "branch3") && repo2.GetBranches ().All (b => b.Name != "branch2"), "Failed to rename branch");
+ }
+
+ [Test]
+ public void TestGitSyncBranches ()
+ {
+ var repo2 = (GitRepository)Repo;
+ AddFile ("file1", "text", true, true);
+ PostCommit (repo2);
+
+ repo2.CreateBranch ("branch3", null);
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "branch3");
+ AddFile ("file2", "asdf", true, true);
+ repo2.Push (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "origin", "branch3");
+
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "master");
+
+ repo2.CreateBranch ("branch4", "origin/branch3");
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "branch4");
+ Assert.IsTrue (File.Exists (RootCheckout + "file2"), "Tracking remote is not grabbing correct commits");
+ }
+
+ [Test]
+ public void TestPushChangeset ()
+ {
+ var repo2 = (GitRepository)Repo;
+ AddFile ("file", "meh", true, true);
+ PostCommit (repo2);
+
+ AddFile ("file1", "text", true, true);
+ AddFile ("file2", "text2", true, true);
+
+ ChangeSet diff = repo2.GetPushChangeSet ("origin", "master");
+ Assert.AreEqual (2, diff.Items.Count ());
+
+ ChangeSetItem item = diff.GetFileItem (RootCheckout + "file1");
+ Assert.IsNotNull (item);
+ Assert.AreEqual (VersionStatus.ScheduledAdd, item.Status & VersionStatus.ScheduledAdd);
+
+ item = diff.GetFileItem (RootCheckout + "file1");
+ Assert.IsNotNull (item);
+ Assert.AreEqual (VersionStatus.ScheduledAdd, item.Status & VersionStatus.ScheduledAdd);
+ }
+
+ [Test]
+ [Ignore ("GetPushDiff content is always empty")]
+ public void TestPushDiff ()
+ {
+ var repo2 = (GitRepository)Repo;
+ AddFile ("file", "meh", true, true);
+ PostCommit (repo2);
+
+ AddFile ("file1", "text", true, true);
+ AddFile ("file2", "text2", true, true);
+
+ DiffInfo[] diff = repo2.GetPushDiff ("origin", "master");
+ Assert.AreEqual (2, diff.Length);
+
+ DiffInfo item = diff [0];
+ Assert.IsNotNull (item);
+ Assert.AreEqual ("file1", item.FileName.FileName);
+ //Assert.AreEqual ("text", item.Content);
+
+ item = diff [1];
+ Assert.IsNotNull (item);
+ Assert.AreEqual ("file2", item.FileName.FileName);
+ //Assert.AreEqual ("text2", item.Content);
+ }
+
+ [Test]
+ public void TestGitUrl ()
+ {
+ var repo2 = (GitRepository)Repo;
+ Assert.IsTrue (repo2.IsUrlValid ("[email protected]:mono/monodevelop"));
+ Assert.IsTrue (repo2.IsUrlValid ("git://github.com:80/mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("ssh://[email protected]:80/mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("http://github.com:80/mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("https://github.com:80/mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("ftp://github.com:80/mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("ftps://github.com:80/mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("file:///mono/monodevelop.git"));
+ Assert.IsTrue (repo2.IsUrlValid ("rsync://github.com/mono/monodevelpo.git"));
+ }
+
+ [Test]
+ public void TestRemote ()
+ {
+ var repo2 = (GitRepository)Repo;
+
+ Assert.AreEqual ("origin", repo2.GetCurrentRemote ());
+
+ AddFile ("file1", "text", true, true);
+ PostCommit (repo2);
+ repo2.CreateBranch ("branch1", null);
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "branch1");
+ AddFile ("file2", "text", true, true);
+ PostCommit (repo2);
+ Assert.AreEqual (2, repo2.GetBranches ().Count ());
+ Assert.AreEqual (1, repo2.GetRemotes ().Count ());
+
+ repo2.RenameRemote ("origin", "other");
+ Assert.AreEqual ("other", repo2.GetCurrentRemote ());
+
+ repo2.RemoveRemote ("other");
+ Assert.IsFalse (repo2.GetRemotes ().Any ());
+ }
+
+ [Test]
+ public void TestIsMerged ()
+ {
+ var repo2 = (GitRepository)Repo;
+ AddFile ("file1", "text", true, true);
+
+ Assert.IsTrue (repo2.IsBranchMerged ("master"));
+
+ repo2.CreateBranch ("branch1", null);
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "branch1");
+ AddFile ("file2", "text", true, true);
+
+ repo2.SwitchToBranch (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), "master");
+ Assert.IsFalse (repo2.IsBranchMerged ("branch1"));
+ repo2.Merge ("branch1", GitUpdateOptions.NormalUpdate, new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor ());
+ Assert.IsTrue (repo2.IsBranchMerged ("branch1"));
+ }
+
+ [Test]
+ public void TestTags ()
+ {
+ var repo2 = (GitRepository)Repo;
+ AddFile ("file1", "text", true, true);
+ repo2.AddTag ("tag1", GetHeadRevision (), "my-tag");
+ Assert.AreEqual (1, repo2.GetTags ().Count ());
+ Assert.AreEqual ("tag1", repo2.GetTags ().First ());
+ repo2.RemoveTag ("tag1");
+ Assert.AreEqual (0, repo2.GetTags ().Count ());
+ }
+
+ // TODO: Test rebase and merge - This is broken on Windows
+
protected override Repository GetRepo (string path, string url)
{
return new GitRepository (path, url);
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Git.Tests/BaseRepositoryTests.cs
===================================================================
@@ -35,7 +35,7 @@
namespace MonoDevelop.VersionControl.Tests
{
[TestFixture]
- public abstract class BaseRepoUtilsTest
+ abstract class BaseRepoUtilsTest
{
// [Git] Set user and email.
protected const string Author = "author";
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitRepository.cs
===================================================================
@@ -1557,7 +1557,7 @@ public ChangeSet GetPushChangeSet (string remote, string branch)
ChangeSet cset = CreateChangeSet (RootPath);
ObjectId cid1 = RootRepository.Resolve (remote + "/" + branch);
ObjectId cid2 = RootRepository.Resolve (RootRepository.GetBranch ());
- RevWalk rw = new RevWalk (RootRepository);
+ RevWalk rw = new RevWalk (RootRepository);
RevCommit c1 = rw.ParseCommit (cid1);
RevCommit c2 = rw.ParseCommit (cid2);
@@ -1589,7 +1589,7 @@ public DiffInfo[] GetPushDiff (string remote, string branch)
RevCommit c2 = rw.ParseCommit (cid2);
List<DiffInfo> diffs = new List<DiffInfo> ();
- foreach (var change in GitUtil.CompareCommits (RootRepository, c1, c2)) {
+ foreach (var change in GitUtil.CompareCommits (RootRepository, c2, c1)) {
string diff;
switch (change.GetChangeType ()) {
case DiffEntry.ChangeType.DELETE:
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/BaseSvnRepositoryTests.cs
===================================================================
@@ -33,9 +33,9 @@
namespace MonoDevelop.VersionControl.Subversion.Tests
{
[TestFixture]
- public abstract class BaseSvnUtilsTest : BaseRepoUtilsTest
+ abstract class BaseSvnUtilsTest : BaseRepoUtilsTest
{
- protected Process svnServe = null;
+ protected Process SvnServe = null;
[SetUp]
public override void Setup ()
@@ -59,13 +59,13 @@ public override void Setup ()
// Create host (Win32)
// This needs to be done after doing the svnAdmin creation.
// And before checkout.
- if (svnServe != null) {
+ if (SvnServe != null) {
info = new ProcessStartInfo ();
info.FileName = "svnserve";
info.Arguments = "-dr " + RootUrl;
info.WindowStyle = ProcessWindowStyle.Hidden;
- svnServe.StartInfo = info;
- svnServe.Start ();
+ SvnServe.StartInfo = info;
+ SvnServe.Start ();
// Create user to auth.
using (var perm = File. CreateText (RootUrl + Path.DirectorySeparatorChar + "repo" +
Modified: main/src/addins/VersionControl/MonoDevelop.VersionControl.Subversion.Tests/RepositoryTests.cs
===================================================================
@@ -36,7 +36,7 @@
namespace VersionControl.Subversion.Unix.Tests
{
[TestFixture]
- public class UnixSvnUtilsTest : MonoDevelop.VersionControl.Subversion.Tests.BaseSvnUtilsTest
+ sealed class UnixSvnUtilsTest : MonoDevelop.VersionControl.Subversion.Tests.BaseSvnUtilsTest
{
SubversionBackend SvnClient {
get { return Repo.Svn; }
Modified: main/src/addins/VersionControl/Subversion.Win32.Tests/RepositoryTests.cs
===================================================================
@@ -36,21 +36,21 @@
namespace MonoDevelop.VersionControl.Subversion.Tests
{
[TestFixture]
- public class SharpSvnUtilsTest : BaseSvnUtilsTest
+ sealed class SharpSvnUtilsTest : BaseSvnUtilsTest
{
[SetUp]
public override void Setup ()
{
RootUrl = new FilePath (FileService.CreateTempDirectory ());
RepoLocation = "svn://localhost:3690/repo";
- svnServe = new Process ();
+ SvnServe = new Process ();
base.Setup ();
}
[TearDown]
public override void TearDown ()
{
- svnServe.Kill ();
+ SvnServe.Kill ();
base.TearDown ();
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches