Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez Gual <lluis@novell.com>2011-03-29 23:23:39 +0400
committerLluis Sanchez Gual <lluis@novell.com>2011-03-29 23:23:57 +0400
commit7b7497fdfb3e73dcceeac1fbf304082e3fe9b9e4 (patch)
tree57daeb9ab8a5efce612551beaacdd2761d54a517 /main/src/addins/VersionControl/MonoDevelop.VersionControl.Git
parentf88dce97bc22fda9024c4a155ad46589b1f05ea9 (diff)
Allow creating a git repo when creating a new solution
Diffstat (limited to 'main/src/addins/VersionControl/MonoDevelop.VersionControl.Git')
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/Makefile.am1
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml4
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj1
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitSupportFeature.cs87
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitUtil.cs25
5 files changed, 106 insertions, 12 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/Makefile.am b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/Makefile.am
index a845237b10..7130261695 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/Makefile.am
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/Makefile.am
@@ -49,6 +49,7 @@ FILES = \
MonoDevelop.VersionControl.Git/GitOptionsPanelWidget.cs \
MonoDevelop.VersionControl.Git/GitRepository.cs \
MonoDevelop.VersionControl.Git/GitService.cs \
+ MonoDevelop.VersionControl.Git/GitSupportFeature.cs \
MonoDevelop.VersionControl.Git/GitUtil.cs \
MonoDevelop.VersionControl.Git/GitVersionControl.cs \
MonoDevelop.VersionControl.Git/MergeDialog.cs \
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml
index 444122e679..cffe748780 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.addin.xml
@@ -100,4 +100,8 @@
<StockIcon stockid = "vc-git-source" resource = "server.png" />
<StockIcon stockid = "vc-git-branch" resource = "arrow_branch.png" />
</Extension>
+
+ <Extension path = "/MonoDevelop/Ide/ProjectFeatures">
+ <Class class = "MonoDevelop.VersionControl.Git.GitSupportFeature" />
+ </Extension>
</Addin>
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj
index 0fc1ed5a3b..cd3312151c 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git.csproj
@@ -79,6 +79,7 @@
<Compile Include="MonoDevelop.VersionControl.Git\GitCommitDialogExtensionWidget.cs" />
<Compile Include="gtk-gui\MonoDevelop.VersionControl.Git.GitCommitDialogExtensionWidget.cs" />
<Compile Include="MonoDevelop.VersionControl.Git\GitCommitDialogExtension.cs" />
+ <Compile Include="MonoDevelop.VersionControl.Git\GitSupportFeature.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\core\MonoDevelop.Core\MonoDevelop.Core.csproj">
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitSupportFeature.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitSupportFeature.cs
new file mode 100644
index 0000000000..31c01c4ff5
--- /dev/null
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitSupportFeature.cs
@@ -0,0 +1,87 @@
+//
+// GitSupportFeature.cs
+//
+// Author:
+// Lluis Sanchez Gual <lluis@novell.com>
+//
+// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using MonoDevelop.Ide.Templates;
+using MonoDevelop.Core;
+using MonoDevelop.Projects;
+using System.Linq;
+
+namespace MonoDevelop.VersionControl.Git
+{
+ public class GitSupportFeature: ISolutionItemFeature
+ {
+ public FeatureSupportLevel GetSupportLevel (SolutionFolder parentFolder, SolutionItem entry)
+ {
+ if (parentFolder != null && !parentFolder.ParentSolution.FileName.IsNullOrEmpty && System.IO.File.Exists (parentFolder.ParentSolution.FileName))
+ return FeatureSupportLevel.NotSupported;
+ return FeatureSupportLevel.SupportedByDefault;
+ }
+
+ public Gtk.Widget CreateFeatureEditor (SolutionFolder parentCombine, SolutionItem entry)
+ {
+ Gtk.Label label = new Gtk.Label (GettextCatalog.GetString ("A new local Git Repository for the solution will be created"));
+ label.Show ();
+ return label;
+ }
+
+ public string Validate (SolutionFolder parentCombine, SolutionItem entry, Gtk.Widget editor)
+ {
+ return null;
+ }
+
+ public void ApplyFeature (SolutionFolder parentFolder, SolutionItem entry, Gtk.Widget editor)
+ {
+ // The solution may not be saved yet
+ if (parentFolder.ParentSolution.FileName.IsNullOrEmpty || !System.IO.File.Exists (parentFolder.ParentSolution.FileName))
+ parentFolder.ParentSolution.Saved += OnSolutionSaved;
+ else
+ OnSolutionSaved (parentFolder.ParentSolution, null);
+ }
+
+ void OnSolutionSaved (object o, EventArgs a)
+ {
+ Solution sol = (Solution)o;
+ sol.Saved -= OnSolutionSaved;
+ var repo = GitUtil.Init (sol.BaseDirectory, null, null);
+
+ GitRepository gitRepo = new GitRepository (sol.BaseDirectory, null);
+ gitRepo.Add (sol.GetItemFiles (true).ToArray (), false, new MonoDevelop.Core.ProgressMonitoring.NullProgressMonitor ());
+ }
+
+ public string Title {
+ get {
+ return GettextCatalog.GetString ("Git Support");
+ }
+ }
+
+ public string Description {
+ get {
+ return GettextCatalog.GetString ("Git options for the new project");
+ }
+ }
+ }
+}
+
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitUtil.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitUtil.cs
index 0985f6ff7f..492905cd72 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitUtil.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl.Git/MonoDevelop.VersionControl.Git/GitUtil.cs
@@ -323,7 +323,7 @@ namespace MonoDevelop.VersionControl.Git
InitCommand ci = new InitCommand ();
ci.SetDirectory (targetLocalPath);
ci.Call ();
- LocalGitRepository repo = new LocalGitRepository (targetLocalPath);
+ LocalGitRepository repo = new LocalGitRepository (Path.Combine (targetLocalPath, Constants.DOT_GIT));
string branch = Constants.R_HEADS + "master";
@@ -331,21 +331,22 @@ namespace MonoDevelop.VersionControl.Git
head.DisableRefLog ();
head.Link (branch);
- RemoteConfig remoteConfig = new RemoteConfig (repo.GetConfig (), "origin");
- remoteConfig.AddURI (new URIish (url));
-
- string dst = Constants.R_REMOTES + remoteConfig.Name;
- RefSpec wcrs = new RefSpec();
- wcrs = wcrs.SetForceUpdate (true);
- wcrs = wcrs.SetSourceDestination (Constants.R_HEADS + "*", dst + "/*");
-
- remoteConfig.AddFetchRefSpec (wcrs);
+ if (url != null) {
+ RemoteConfig remoteConfig = new RemoteConfig (repo.GetConfig (), "origin");
+ remoteConfig.AddURI (new URIish (url));
+
+ string dst = Constants.R_REMOTES + remoteConfig.Name;
+ RefSpec wcrs = new RefSpec();
+ wcrs = wcrs.SetForceUpdate (true);
+ wcrs = wcrs.SetSourceDestination (Constants.R_HEADS + "*", dst + "/*");
+
+ remoteConfig.AddFetchRefSpec (wcrs);
+ remoteConfig.Update (repo.GetConfig());
+ }
// we're setting up for a clone with a checkout
repo.GetConfig().SetBoolean ("core", null, "bare", false);
- remoteConfig.Update (repo.GetConfig());
-
repo.GetConfig().Save();
return repo;
}