Пример #1
0
		public EditRemoteDialog (RemoteSource remote, bool isNew)
		{
			this.Build ();
			this.remote = remote;
			
			updating = true;
			entryName.Text = remote.Name;
			entryUrl.Text = remote.FetchUrl ?? "";
			entryPushUrl.Text = string.IsNullOrEmpty (remote.PushUrl) ? remote.FetchUrl : remote.PushUrl;
			if (!isNew)
				checkImportTags.Visible = false;
			updating = false;
			UpdateButtons ();
		}
Пример #2
0
		public void UpdateRemote (RemoteSource remote)
		{
			if (string.IsNullOrEmpty (remote.FetchUrl))
				throw new InvalidOperationException ("Fetch url can't be empty");
			
			if (remote.RepoRemote == null)
				throw new InvalidOperationException ("Remote not created");
			
			remote.Update ();
			remote.cfg.Save ();
		}
Пример #3
0
		public void AddRemote (RemoteSource remote, bool importTags)
		{
			if (string.IsNullOrEmpty (remote.Name))
				throw new InvalidOperationException ("Name not set");
			
			StoredConfig c = RootRepository.GetConfig ();
			RemoteConfig rc = new RemoteConfig (c, remote.Name);
			c.Save ();
			remote.RepoRemote = rc;
			remote.cfg = c;
			UpdateRemote (remote);
		}
Пример #4
0
		protected virtual void OnButtonAddRemoteClicked (object sender, System.EventArgs e)
		{
			var remote = new RemoteSource ();
			var dlg = new EditRemoteDialog (remote, true);
			try {
				if (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok) {
					repo.AddRemote (remote, dlg.ImportTags);
					FillRemotes ();
				}
			} finally {
				dlg.Destroy ();
			}
		}
Пример #5
0
		public void UpdateRemote (RemoteSource remote)
		{
			if (string.IsNullOrEmpty (remote.FetchUrl))
				throw new InvalidOperationException ("Fetch url can't be empty");
			
			RunCommand ("remote set-url " + remote.Name + " " + remote.FetchUrl, true);
			
			if (!string.IsNullOrEmpty (remote.PushUrl))
				RunCommand ("remote set-url --push " + remote.Name + " " + remote.PushUrl, true);
			else
				RunCommand ("remote set-url --push --delete " + remote.Name + " " + remote.PushUrl, true);
		}
Пример #6
0
		public void AddRemote (RemoteSource remote, bool importTags)
		{
			RunCommand ("remote add " + (importTags ? "--tags " : "--no-tags ") + remote.Name + " " + remote.FetchUrl, true);
			if (!string.IsNullOrEmpty (remote.PushUrl) && remote.PushUrl != remote.FetchUrl)
				RunCommand ("remote set-url --push " + remote.Name + " " + remote.PushUrl, true);
		}
Пример #7
0
		public IEnumerable<RemoteSource> GetRemotes ()
		{
			StringReader sr = RunCommand ("remote -v", true);
			string line;
			List<RemoteSource> sources = new List<RemoteSource> ();
			while ((line = sr.ReadLine ()) != null) {
				int i = line.IndexOf ('\t');
				if (i == -1)
					continue;
				string name = line.Substring (0, i);
				RemoteSource remote = sources.FirstOrDefault (r => r.Name == name);
				if (remote == null) {
					remote = new RemoteSource ();
					remote.Name = name;
					sources.Add (remote);
				}
				int j = line.IndexOf (" (fetch)");
				if (j != -1) {
					remote.FetchUrl = line.Substring (i, line.Length - i - 8).Trim ();
				} else {
					j = line.IndexOf (" (push)");
					remote.PushUrl = line.Substring (i, line.Length - i - 7).Trim ();
				}
			}
			return sources;
		}