| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001426232310d-ee1d156d-a73c-4532-b439-aa3fbbb1035e-000000@email.amazonses.com> |
Branch: refs/heads/vcsTests
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/8a9f2273d0a6...9ade8bf0ff0f
Commit: 9ade8bf0ff0fe234d32beb3106f4514beaef7589
Author: Therzok <[email protected]> (Therzok)
Date: 2013-11-16 18:33:57 GMT
URL: https://github.com/mono/monodevelop/commit/9ade8bf0ff0fe234d32beb3106f4514beaef7589
[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 ()
@@ -51,11 +51,11 @@ public override void Setup ()
RepoLocation = "file:///" + RootUrl.FullPath + "repo.git";
// Initialize the bare repo.
- InitCommand ci = new InitCommand ();
+ var ci = new InitCommand ();
ci.SetDirectory (new Sharpen.FilePath (RootUrl.FullPath + "repo.git"));
ci.SetBare (true);
ci.Call ();
- FileRepository bare = new FileRepository (new Sharpen.FilePath (RootUrl.FullPath + "repo.git"));
+ var bare = new FileRepository (new Sharpen.FilePath (RootUrl.FullPath + "repo.git"));
string branch = Constants.R_HEADS + "master";
RefUpdate head = bare.UpdateRef (Constants.HEAD);
@@ -132,21 +132,21 @@ public override void MovesDirectory ()
protected override Revision GetHeadRevision ()
{
- GitRepository repo2 = (GitRepository)Repo;
- RevWalk rw = new RevWalk (repo2.RootRepository);
+ var repo2 = (GitRepository)Repo;
+ var rw = new RevWalk (repo2.RootRepository);
ObjectId headId = repo2.RootRepository.Resolve (Constants.HEAD);
if (headId == null)
return null;
RevCommit commit = rw.ParseCommit (headId);
- GitRevision rev = new GitRevision (Repo, repo2.RootRepository, commit.Id.Name);
+ var rev = new GitRevision (Repo, repo2.RootRepository, commit.Id.Name);
rev.Commit = commit;
return rev;
}
protected override void PostCommit (Repository repo)
{
- GitRepository repo2 = (GitRepository)repo;
+ var repo2 = (GitRepository)repo;
repo2.Push (new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor (), repo2.GetCurrentRemote (), repo2.GetCurrentBranch ());
}
@@ -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";
@@ -48,7 +48,7 @@ public abstract class BaseRepoUtilsTest
protected Repository Repo2;
protected string DotDir;
protected List<string> AddedItems = new List<string> ();
- protected int CommitNumber = 0;
+ protected int CommitNumber;
[SetUp]
public abstract void Setup ();
@@ -168,7 +168,7 @@ public virtual void UpdateIsDone ()
PostCommit (Repo);
// Checkout a second repository.
- FilePath second = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar);
+ var second = new FilePath (FileService.CreateTempDirectory () + Path.DirectorySeparatorChar);
Checkout (second, RepoLocation);
Repo2 = GetRepo (second, RepoLocation);
string added = second + "testfile2";
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);
+ var rw = new RevWalk (RootRepository);
RevCommit c1 = rw.ParseCommit (cid1);
RevCommit c2 = rw.ParseCommit (cid2);
@@ -1574,7 +1574,7 @@ public ChangeSet GetPushChangeSet (string remote, string branch)
status = VersionStatus.Modified;
break;
}
- VersionInfo vi = new VersionInfo (RootRepository.FromGitPath (change.GetNewPath ()), "", false, status | VersionStatus.Versioned, null, VersionStatus.Versioned, null);
+ var vi = new VersionInfo (RootRepository.FromGitPath (change.GetNewPath ()), "", false, status | VersionStatus.Versioned, null, VersionStatus.Versioned, null);
cset.AddFile (vi);
}
return cset;
@@ -1584,12 +1584,12 @@ public DiffInfo[] GetPushDiff (string remote, string branch)
{
ObjectId cid1 = RootRepository.Resolve (remote + "/" + branch);
ObjectId cid2 = RootRepository.Resolve (RootRepository.GetBranch ());
- RevWalk rw = new RevWalk (RootRepository);
+ var rw = new RevWalk (RootRepository);
RevCommit c1 = rw.ParseCommit (cid1);
RevCommit c2 = rw.ParseCommit (cid2);
- List<DiffInfo> diffs = new List<DiffInfo> ();
- foreach (var change in GitUtil.CompareCommits (RootRepository, c1, c2)) {
+ var diffs = new List<DiffInfo> ();
+ foreach (var change in GitUtil.CompareCommits (RootRepository, c2, c1)) {
string diff;
switch (change.GetChangeType ()) {
case DiffEntry.ChangeType.DELETE:
@@ -1602,7 +1602,7 @@ public DiffInfo[] GetPushDiff (string remote, string branch)
diff = GenerateDiff (GetCommitContent (c1, change.GetNewPath ()), GetCommitContent (c2, change.GetNewPath ()));
break;
}
- DiffInfo di = new DiffInfo (RootPath, RootRepository.FromGitPath (change.GetNewPath ()), diff);
+ var di = new DiffInfo (RootPath, RootRepository.FromGitPath (change.GetNewPath ()), diff);
diffs.Add (di);
}
return diffs.ToArray ();
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