GetCurrentRemote() 공개 메소드

public GetCurrentRemote ( ) : string
리턴 string
		public GitCommitDialogExtensionWidget (GitRepository repo)
		{
			this.Build ();

			bool hasRemote = repo.GetCurrentRemote () != null;
			if (!hasRemote) {
				checkPush.Sensitive = false;
				checkPush.TooltipText = GettextCatalog.GetString ("Pushing is only available for repositories with configured remotes.");
			}
		}
예제 #2
0
		public PushDialog (GitRepository repo)
		{
			this.Build ();
			this.repo = repo;
			HasSeparator = false;
			
			changeList.DiffLoader = DiffLoader;
			
			List<string> list = new List<string> (repo.GetRemotes ().Select (r => r.Name));
			foreach (string s in list)
				remoteCombo.AppendText (s);
			remoteCombo.Active = list.IndexOf (repo.GetCurrentRemote ());
			
			UpdateChangeSet ();
		}
예제 #3
0
		async Task AddXwtFromGithubAsync (Solution solution, string newProjectName, bool createSubmodule, ProgressMonitor monitor)
		{
			try {
				var gitUrl = "https://github.com/" + (string.IsNullOrEmpty (Parameters ["XwtGithubRepository"]) ? Parameters ["XwtGithubRepository"] : "mono/xwt") + ".git";
				var gitBranch = Parameters ["XwtGithubBranch"];
				if (gitBranch == String.Empty)
					gitBranch = "master";
				var gitRepo = VersionControlService.GetRepository (solution) as GitRepository;
				var xwt_proj = solution.FindProjectByName ("Xwt") as DotNetProject;

				if (xwt_proj != null && xwt_proj.ItemId.ToUpper () != "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
					xwt_proj = null;
					foreach (var item in solution.GetAllProjectsWithFlavor<DotNetProjectExtension>()) {
						if (item.ItemId.ToUpper () == "{92494904-35FA-4DC9-BDE9-3A3E87AC49D3}") {
							xwt_proj = item as DotNetProject;
							break;
						}
					}
				}

				var xwt_path = xwt_proj == null ? solution.BaseDirectory.Combine ("Xwt") : xwt_proj.BaseDirectory.ParentDirectory;

				monitor.BeginTask ("Configuring Xwt References...", 3);

				if (xwt_proj == null && !Directory.Exists (xwt_path)) {
					monitor.BeginTask ("Cloning Xwt into " + xwt_path + "...", 1);
					if (createSubmodule && gitRepo != null) {
						monitor.BeginTask ("Initializing Xwt submodule in " + xwt_path + "...", 1);

						var repo = new FileRepository (gitRepo.RootPath.Combine (".git"));
						var git = new Git (repo);

						try {
							using (var gm = new GitMonitor (monitor)) {
								var add_submodule = git.SubmoduleAdd ();
								add_submodule.SetPath ("Xwt");
								add_submodule.SetURI (gitUrl);
								add_submodule.SetProgressMonitor (gm);
								add_submodule.Call ();

								var submodule = new GitRepository (VersionControlService.GetVersionControlSystems ().First (id => id.Name == "Git"),
												   gitRepo.RootPath.Combine ("Xwt"), gitUrl);

								var submoduleRemote = submodule.GetCurrentRemote ();
								submodule.Fetch (monitor, submoduleRemote);
								if (submodule.GetCurrentBranch () != gitBranch) {
									submodule.CreateBranch (gitBranch, submoduleRemote + "/" + gitBranch, "refs/remotes/" + submoduleRemote + "/" + gitBranch);
									submodule.SwitchToBranch (monitor, gitBranch);
								}
							}
						} catch {
							Directory.Delete (xwt_path, true);
							throw;
						}

						monitor.EndTask ();
					} else {

						var repo = new GitRepository ();
						repo.Url = gitUrl;
						repo.Checkout (xwt_path, true, monitor);
						var remote = repo.GetCurrentRemote ();
						repo.Fetch (monitor, remote);
						if (repo.GetCurrentBranch () != gitBranch) {
							repo.CreateBranch (gitBranch, remote + "/" + gitBranch, "refs/remotes/" + remote + "/" + gitBranch);
							repo.SwitchToBranch (monitor, gitBranch);
						}
					}
					monitor.EndTask ();
				}

				SolutionFolder xwt_folder;
				if (xwt_proj != null)
					xwt_folder = xwt_proj.ParentFolder;
				else {
					xwt_folder = new SolutionFolder ();
					xwt_folder.Name = "Xwt";
				}
				solution.RootFolder.Items.Add (xwt_folder);
				monitor.Step (1);

				monitor.BeginTask ("Adding Xwt Projects to Solution...", 7);

				if (xwt_proj == null && File.Exists (xwt_path.Combine ("Xwt", "Xwt.csproj"))) {
					xwt_proj = await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt", "Xwt.csproj")
					) as DotNetProject;
				}
				if (xwt_proj == null)
					throw new InvalidOperationException ("Xwt project not found");

				monitor.Step (1);

				var xwt_gtk_proj = solution.FindProjectByName ("Xwt.Gtk") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_win_proj = solution.FindProjectByName ("Xwt.Gtk.Windows") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Windows", "Xwt.Gtk.Windows.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk_mac_proj = solution.FindProjectByName ("Xwt.Gtk.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk.Mac", "Xwt.Gtk.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_gtk3_proj = solution.FindProjectByName ("Xwt.Gtk3") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Gtk", "Xwt.Gtk3.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_wpf_proj = solution.FindProjectByName ("Xwt.WPF") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.WPF", "Xwt.WPF.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_mac_proj = solution.FindProjectByName ("Xwt.Mac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.Mac", "Xwt.Mac.csproj")
					) as DotNetProject;

				monitor.Step (1);

				var xwt_xammac_proj = solution.FindProjectByName ("Xwt.XamMac") ??
					await IdeApp.ProjectOperations.AddSolutionItem (
						xwt_folder,
						xwt_path.Combine ("Xwt.XamMac", "Xwt.XamMac.csproj")
					) as DotNetProject;


				monitor.EndTask ();
				monitor.Step (1);
				monitor.BeginTask ("Adding Xwt References...", solution.Items.Count);

				foreach (var item in solution.Items) {
					var project = item as DotNetProject;
					if (project != null) {
						if (project.Name == newProjectName ||
						    project.Name.StartsWith (newProjectName + ".", StringComparison.Ordinal))
							project.References.Add (ProjectReference.CreateProjectReference (xwt_proj));
						
						if (project.Name == newProjectName + ".Desktop") {
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsLinux) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Gtk2") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_proj));
							if (Platform.IsWindows) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_win_proj));
							} else if (Platform.IsMac) {
								project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk_mac_proj));
							}
						}

						if (project.Name == newProjectName + ".Wpf") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_wpf_proj));
						}

						if (project.Name == newProjectName + ".Gtk3") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_gtk3_proj));
						}

						if (project.Name == newProjectName + ".Mac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_mac_proj));
						}

						if (project.Name == newProjectName + ".XamMac") {
							project.References.Add (ProjectReference.CreateProjectReference (xwt_xammac_proj));
						}
					}
					monitor.Step (1);
				}

				monitor.EndTask ();
				monitor.EndTask ();
				monitor.ReportSuccess ("Xwt Repository initialized successfully");

				await IdeApp.Workspace.SaveAsync (monitor);
			} catch (Exception e) {
				string msg = GettextCatalog.GetString ("Adding Xwt reference failed: ");
				monitor.ReportError (msg, e);
				MessageService.ShowError (msg, e);
			} finally {
				monitor.Dispose ();
			}
		}