예제 #1
0
파일: URIishTest.cs 프로젝트: nnieslan/ngit
 public virtual void TestFileProtocol()
 {
     // as defined by git docu
     URIish u = new URIish("file:///a/b.txt");
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
     FilePath tmp = FilePath.CreateTempFile("jgitUnitTest", ".tmp");
     u = new URIish(tmp.ToURI().ToString());
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.IsTrue(u.GetPath().Contains("jgitUnitTest"));
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.IsTrue(u.GetHumanishName().StartsWith("jgitUnitTest"));
     u = new URIish("file:/a/b.txt");
     NUnit.Framework.Assert.AreEqual("file", u.GetScheme());
     NUnit.Framework.Assert.IsFalse(u.IsRemote());
     NUnit.Framework.Assert.IsNull(u.GetHost());
     NUnit.Framework.Assert.IsNull(u.GetPass());
     NUnit.Framework.Assert.AreEqual("/a/b.txt", u.GetPath());
     NUnit.Framework.Assert.AreEqual(-1, u.GetPort());
     NUnit.Framework.Assert.IsNull(u.GetUser());
     NUnit.Framework.Assert.AreEqual("b.txt", u.GetHumanishName());
 }
예제 #2
0
		public virtual void TestPush()
		{
			// create other repository
			Repository db2 = CreateWorkRepository();
			// setup the first repository
			StoredConfig config = ((FileBasedConfig)db.GetConfig());
			RemoteConfig remoteConfig = new RemoteConfig(config, "test");
			URIish uri = new URIish(db2.Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.Update(config);
			config.Save();
			Git git1 = new Git(db);
			// create some refs via commits and tag
			RevCommit commit = git1.Commit().SetMessage("initial commit").Call();
			Ref tagRef = git1.Tag().SetName("tag").Call();
			try
			{
				db2.Resolve(commit.Id.GetName() + "^{commit}");
				NUnit.Framework.Assert.Fail("id shouldn't exist yet");
			}
			catch (MissingObjectException)
			{
			}
			// we should get here
			RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
			git1.Push().SetRemote("test").SetRefSpecs(spec).Call();
			NUnit.Framework.Assert.AreEqual(commit.Id, db2.Resolve(commit.Id.GetName() + "^{commit}"
				));
			NUnit.Framework.Assert.AreEqual(tagRef.GetObjectId(), db2.Resolve(tagRef.GetObjectId
				().GetName()));
		}
		public override bool Get (URIish uri, params CredentialItem[] items)
		{
			bool result = false;
			CredentialItem.Password passwordItem = null;
			CredentialItem.StringType passphraseItem = null;
			
			// We always need to run the TryGet* methods as we need the passphraseItem/passwordItem populated even
			// if the password store contains an invalid password/no password
			if (TryGetUsernamePassword (uri, items, out passwordItem) || TryGetPassphrase (uri, items, out passphraseItem)) {
				// If the password store has a password and we already tried using it, it could be incorrect.
				// If this happens, do not return true and ask the user for a new password.
				if (!HasReset) {
					return true;
				}
			}

			DispatchService.GuiSyncDispatch (delegate {
				CredentialsDialog dlg = new CredentialsDialog (uri, items);
				try {
					result = MessageService.ShowCustomDialog (dlg) == (int)Gtk.ResponseType.Ok;
				} finally {
					dlg.Destroy ();
				}
			});
				
			HasReset = false;
			if (result) {
				if (passwordItem != null) {
					PasswordService.AddWebPassword (new Uri (uri.ToString ()), new string (passwordItem.GetValue ()));
				} else if (passphraseItem != null) {
					PasswordService.AddWebPassword (new Uri (uri.ToString ()), passphraseItem.GetValue ());
				}
			}
			return result;
		}
예제 #4
0
		internal static bool CanHandle(URIish uri)
		{
			if (!uri.IsRemote())
			{
				return false;
			}
			string scheme = uri.GetScheme();
			if ("ssh".Equals(scheme))
			{
				return true;
			}
			if ("ssh+git".Equals(scheme))
			{
				return true;
			}
			if ("git+ssh".Equals(scheme))
			{
				return true;
			}
			if (scheme == null && uri.GetHost() != null && uri.GetPath() != null)
			{
				return true;
			}
			return false;
		}
예제 #5
0
		internal static bool CanHandle(URIish uri)
		{
			if (!uri.IsRemote())
			{
				return false;
			}
			return S3_SCHEME.Equals(uri.GetScheme());
		}
예제 #6
0
		public CredentialsDialog (URIish uri, IEnumerable<CredentialItem> credentials)
		{
			this.Build ();
			this.credentials = credentials;
			
			labelTop.Text = string.Format (labelTop.Text, uri.ToString ());
			
			Gtk.Table table = new Gtk.Table (0, 0, false);
			table.ColumnSpacing = 6;
			vbox.PackStart (table, true, true, 0);
			
			uint r = 0;
			Widget firstEditor = null;
			foreach (CredentialItem c in credentials) {
				Label lab = new Label (c.GetPromptText () + ":");
				lab.Xalign = 0;
				table.Attach (lab, 0, 1, r, r + 1);
				Table.TableChild tc = (Table.TableChild) table [lab];
				tc.XOptions = AttachOptions.Shrink;
				
				Widget editor = null;
				
				if (c is CredentialItem.YesNoType) {
					CredentialItem.YesNoType cred = (CredentialItem.YesNoType) c;
					CheckButton btn = new CheckButton ();
					editor = btn;
					btn.Toggled += delegate {
						cred.SetValue (btn.Active);
					};
				}
				else if (c is CredentialItem.StringType || c is CredentialItem.CharArrayType) {
					CredentialItem cred = c;
					Entry e = new Entry ();
					editor = e;
					e.ActivatesDefault = true;
					if (cred.IsValueSecure ())
						e.Visibility = false;
					e.Changed += delegate {
						if (cred is CredentialItem.StringType)
							((CredentialItem.StringType)cred).SetValue (e.Text);
						else
							((CredentialItem.CharArrayType)cred).SetValue (e.Text.ToCharArray ());
					};
				}
				if (editor != null) {
					table.Attach (editor, 1, 2, r, r + 1);
					tc = (Table.TableChild) table [lab];
					tc.XOptions = AttachOptions.Fill;
					if (firstEditor == null)
						firstEditor = editor;
				}
				
				r++;
			}
			table.ShowAll ();
			Focus = firstEditor;
			Default = buttonOk;
		}
예제 #7
0
		public override bool IsUrlValid (string url)
		{
			try {
				NGit.Transport.URIish u = new NGit.Transport.URIish (url);
				return true;
			} catch {
				return false;
			}
		}
		private static URIish CreateURI(Session session)
		{
			URIish uri = new URIish();
			uri = uri.SetScheme("ssh");
			uri = uri.SetUser(session.GetUserName());
			uri = uri.SetHost(session.GetHost());
			uri = uri.SetPort(session.GetPort());
			return uri;
		}
예제 #9
0
			public override bool CanHandle(URIish uri, Repository local, string remoteName)
			{
				if (uri.GetPath() == null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
					() != null || uri.GetHost() != null || (uri.GetScheme() != null && !this.GetSchemes
					().Contains(uri.GetScheme())))
				{
					return false;
				}
				return true;
			}
예제 #10
0
		public override bool IsUrlValid (string url)
		{
			try {
				NGit.Transport.URIish u = new NGit.Transport.URIish (url);
				if (!string.IsNullOrEmpty (u.GetHost ()))
					return true;
			} catch {
			}
			return base.IsUrlValid (url);
		}
예제 #11
0
		public override bool Get (URIish uri, params CredentialItem[] items)
		{
			bool result = false;
			DispatchService.GuiSyncDispatch (delegate {
				CredentialsDialog dlg = new CredentialsDialog (uri, items);
				try {
					result = MessageService.ShowCustomDialog (dlg) == (int)Gtk.ResponseType.Ok;
				} finally {
					dlg.Destroy ();
				}
			});
			return result;
		}
예제 #12
0
		internal static bool CanHandle(URIish uri, FS fs)
		{
			if (uri.GetHost() != null || uri.GetPort() > 0 || uri.GetUser() != null || uri.GetPass
				() != null || uri.GetPath() == null)
			{
				return false;
			}
			if ("file".Equals(uri.GetScheme()) || uri.GetScheme() == null)
			{
				FilePath f = fs.Resolve(new FilePath("."), uri.GetPath());
				return f.IsFile() || f.GetName().EndsWith(".bundle");
			}
			return false;
		}
예제 #13
0
		public virtual void TestFetch()
		{
			// create other repository
			Repository db2 = CreateWorkRepository();
			Git git2 = new Git(db2);
			// setup the first repository to fetch from the second repository
			StoredConfig config = ((FileBasedConfig)db.GetConfig());
			RemoteConfig remoteConfig = new RemoteConfig(config, "test");
			URIish uri = new URIish(db2.Directory.ToURI().ToURL());
			remoteConfig.AddURI(uri);
			remoteConfig.Update(config);
			config.Save();
			// create some refs via commits and tag
			RevCommit commit = git2.Commit().SetMessage("initial commit").Call();
			RevTag tag = git2.Tag().SetName("tag").Call();
			Git git1 = new Git(db);
			RefSpec spec = new RefSpec("refs/heads/master:refs/heads/x");
			git1.Fetch().SetRemote("test").SetRefSpecs(spec).Call();
			NUnit.Framework.Assert.AreEqual(commit.Id, db.Resolve(commit.Id.GetName() + "^{commit}"
				));
			NUnit.Framework.Assert.AreEqual(tag.Id, db.Resolve(tag.Id.GetName()));
		}
예제 #14
0
 /// <summary>Ask for the credential items to be populated.</summary>
 /// <remarks>Ask for the credential items to be populated.</remarks>
 /// <param name="uri">the URI of the remote resource that needs authentication.</param>
 /// <param name="items">the items the application requires to complete authentication.
 ///     </param>
 /// <returns>
 ///
 /// <code>true</code>
 /// if the request was successful and values were
 /// supplied;
 /// <code>false</code>
 /// if the user canceled the request and did
 /// not supply all requested values.
 /// </returns>
 /// <exception cref="NGit.Errors.UnsupportedCredentialItem">if one of the items supplied is not supported.
 ///     </exception>
 public virtual bool Get(URIish uri, IList <CredentialItem> items)
 {
     return(Get(uri, Sharpen.Collections.ToArray(items, new CredentialItem[items.Count
                                                 ])));
 }
예제 #15
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestGetValidWithEmptySlashDotGitHumanishName()
        {
            string humanishName = new URIish("/a/b/.git").GetHumanishName();

            NUnit.Framework.Assert.AreEqual("b", humanishName);
        }
예제 #16
0
 /// <summary>Wrap a CredentialsProvider to make it suitable for use with JSch.</summary>
 /// <remarks>Wrap a CredentialsProvider to make it suitable for use with JSch.</remarks>
 /// <param name="session">the JSch session this UserInfo will support authentication on.
 ///     </param>
 /// <param name="credentialsProvider">the provider that will perform the authentication.
 ///     </param>
 public CredentialsProviderUserInfo(Session session, CredentialsProvider credentialsProvider
                                    )
 {
     this.uri      = CreateURI(session);
     this.provider = credentialsProvider;
 }
예제 #17
0
			/// <exception cref="NGit.Errors.TransportException"></exception>
			public override RemoteSession GetSession(URIish uri2, CredentialsProvider credentialsProvider
				, FS fs, int tms)
			{
				return new TransportGitSsh.ExtSession(_enclosing);
			}
예제 #18
0
파일: Transport.cs 프로젝트: kenji-tan/ngit
        /// <summary>Open a new transport instance to connect two repositories.</summary>
        /// <remarks>Open a new transport instance to connect two repositories.</remarks>
        /// <param name="local">existing local repository.</param>
        /// <param name="uri">location of the remote repository.</param>
        /// <param name="remoteName">
        /// name of the remote, if the remote as configured in
        /// <code>local</code>
        /// ; otherwise null.
        /// </param>
        /// <returns>the new transport instance. Never null.</returns>
        /// <exception cref="System.NotSupportedException">the protocol specified is not supported.
        /// 	</exception>
        /// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
        /// 	</exception>
        public static NGit.Transport.Transport Open(Repository local, URIish uri, string 
			remoteName)
        {
            foreach (WeakReference<TransportProtocol> @ref in protocols)
            {
                TransportProtocol proto = @ref.Get();
                if (proto == null)
                {
                    protocols.Remove(@ref);
                    continue;
                }
                if (proto.CanHandle(uri, local, remoteName))
                {
                    return proto.Open(uri, local, remoteName);
                }
            }
            throw new NGit.Errors.NotSupportedException(MessageFormat.Format(JGitText.Get().URINotSupported
                , uri));
        }
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public override RemoteSession GetSession(URIish uri, CredentialsProvider credentialsProvider
                                          , FS fs, int tms)
 {
     lock (this)
     {
         string user = uri.GetUser();
         string pass = uri.GetPass();
         string host = uri.GetHost();
         int    port = uri.GetPort();
         try
         {
             if (config == null)
             {
                 config = OpenSshConfig.Get(fs);
             }
             OpenSshConfig.Host hc = config.Lookup(host);
             host = hc.GetHostName();
             if (port <= 0)
             {
                 port = hc.GetPort();
             }
             if (user == null)
             {
                 user = hc.GetUser();
             }
             Session session = CreateSession(credentialsProvider, fs, user, pass, host, port,
                                             hc);
             int retries = 0;
             while (!session.IsConnected() && retries < 3)
             {
                 try
                 {
                     retries++;
                     session.Connect(tms);
                 }
                 catch (JSchException e)
                 {
                     session.Disconnect();
                     session = null;
                     // if authentication failed maybe credentials changed at the
                     // remote end therefore reset credentials and retry
                     if (credentialsProvider != null && e.InnerException == null && e.Message.Equals("Auth fail"
                                                                                                     ) && retries < 3)
                     {
                         credentialsProvider.Reset(uri);
                         session = CreateSession(credentialsProvider, fs, user, pass, host, port, hc);
                     }
                     else
                     {
                         throw;
                     }
                 }
             }
             return(new JschSession(session, uri));
         }
         catch (JSchException je)
         {
             Exception c = je.InnerException;
             if (c is UnknownHostException)
             {
                 throw new TransportException(uri, JGitText.Get().unknownHost);
             }
             if (c is ConnectException)
             {
                 throw new TransportException(uri, c.Message);
             }
             throw new TransportException(uri, je.Message, je);
         }
     }
 }
예제 #20
0
 /// <summary>Create a new transport to fetch objects from a streamed bundle.</summary>
 /// <remarks>
 /// Create a new transport to fetch objects from a streamed bundle.
 /// <p>
 /// The stream can be unbuffered (buffering is automatically provided
 /// internally to smooth out short reads) and unpositionable (the stream is
 /// read from only once, sequentially).
 /// <p>
 /// When the FetchConnection or the this instance is closed the supplied
 /// input stream is also automatically closed. This frees callers from
 /// needing to keep track of the supplied stream.
 /// </remarks>
 /// <param name="db">repository the fetched objects will be loaded into.</param>
 /// <param name="uri">
 /// symbolic name of the source of the stream. The URI can
 /// reference a non-existent resource. It is used only for
 /// exception reporting.
 /// </param>
 /// <param name="in">the stream to read the bundle from.</param>
 public TransportBundleStream(Repository db, URIish uri, InputStream @in) : base(db
                                                                                 , uri)
 {
     src = @in;
 }
예제 #21
0
 internal TransportBundleFile(Repository local, URIish uri, FilePath bundlePath) :
     base(local, uri)
 {
     bundle = bundlePath;
 }
예제 #22
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public override RemoteSession GetSession(URIish uri2, CredentialsProvider credentialsProvider
                                          , FS fs, int tms)
 {
     return(new TransportGitSsh.ExtSession(_enclosing));
 }
예제 #23
0
 /// <summary>Remove a push-only URI from the list of URIs.</summary>
 /// <remarks>Remove a push-only URI from the list of URIs.</remarks>
 /// <param name="toRemove">the URI to remove from this remote.</param>
 /// <returns>true if the URI was added; false if it already exists.</returns>
 public virtual bool RemovePushURI(URIish toRemove)
 {
     return(pushURIs.Remove(toRemove));
 }
예제 #24
0
 /// <summary>Remove a URI from the list of URIs.</summary>
 /// <remarks>Remove a URI from the list of URIs.</remarks>
 /// <param name="toRemove">the URI to remove from this remote.</param>
 /// <returns>true if the URI was added; false if it already exists.</returns>
 public virtual bool RemoveURI(URIish toRemove)
 {
     return(uris.Remove(toRemove));
 }
예제 #25
0
파일: Transport.cs 프로젝트: kenji-tan/ngit
 /// <summary>Create a new transport instance.</summary>
 /// <remarks>Create a new transport instance.</remarks>
 /// <param name="local">
 /// the repository this instance will fetch into, or push out of.
 /// This must be the repository passed to
 /// <see cref="Open(NGit.Repository, URIish)">Open(NGit.Repository, URIish)</see>
 /// .
 /// </param>
 /// <param name="uri">
 /// the URI used to access the remote repository. This must be the
 /// URI passed to
 /// <see cref="Open(NGit.Repository, URIish)">Open(NGit.Repository, URIish)</see>
 /// .
 /// </param>
 protected internal Transport(Repository local, URIish uri)
 {
     TransferConfig tc = local.GetConfig().Get(TransferConfig.KEY);
     this.local = local;
     this.uri = uri;
     this.checkFetchedObjects = tc.IsFsckObjects();
     this.credentialsProvider = CredentialsProvider.GetDefault();
 }
예제 #26
0
 protected internal TransportGitAnon(Repository local, URIish uri) : base(local, uri
                                                                          )
 {
 }
예제 #27
0
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public override RemoteSession GetSession(URIish uri, CredentialsProvider credentialsProvider
                                          , FS fs, int tms)
 {
     lock (this)
     {
         string user = uri.GetUser();
         string pass = uri.GetPass();
         string host = uri.GetHost();
         int    port = uri.GetPort();
         try
         {
             if (config == null)
             {
                 config = OpenSshConfig.Get(fs);
             }
             OpenSshConfig.Host hc = config.Lookup(host);
             host = hc.GetHostName();
             if (port <= 0)
             {
                 port = hc.GetPort();
             }
             if (user == null)
             {
                 user = hc.GetUser();
             }
             Session session = CreateSession(hc, user, host, port, fs);
             if (pass != null)
             {
                 session.SetPassword(pass);
             }
             string strictHostKeyCheckingPolicy = hc.GetStrictHostKeyChecking();
             if (strictHostKeyCheckingPolicy != null)
             {
                 session.SetConfig("StrictHostKeyChecking", strictHostKeyCheckingPolicy);
             }
             string pauth = hc.GetPreferredAuthentications();
             if (pauth != null)
             {
                 session.SetConfig("PreferredAuthentications", pauth);
             }
             if (credentialsProvider != null && (!hc.IsBatchMode() || !credentialsProvider.IsInteractive
                                                     ()))
             {
                 session.SetUserInfo(new CredentialsProviderUserInfo(session, credentialsProvider)
                                     );
             }
             Configure(hc, session);
             if (!session.IsConnected())
             {
                 session.Connect(tms);
             }
             return(new JschSession(session, uri));
         }
         catch (JSchException je)
         {
             Exception c = je.InnerException;
             if (c is UnknownHostException)
             {
                 throw new TransportException(uri, JGitText.Get().unknownHost);
             }
             if (c is ConnectException)
             {
                 throw new TransportException(uri, c.Message);
             }
             throw new TransportException(uri, je.Message, je);
         }
     }
 }
 /// <summary>Create a new transport instance.</summary>
 /// <remarks>Create a new transport instance.</remarks>
 /// <param name="local">
 /// the repository this instance will fetch into, or push out of.
 /// This must be the repository passed to
 /// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
 ///     </see>
 /// .
 /// </param>
 /// <param name="uri">
 /// the URI used to access the remote repository. This must be the
 /// URI passed to
 /// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
 ///     </see>
 /// .
 /// </param>
 protected internal TcpTransport(Repository local, URIish uri) : base(local, uri)
 {
 }
예제 #29
0
        public virtual void TestGetValidWithSlashesDotGitSlashHumanishName()
        {
            string humanishName = new URIish("/a/b/c.git/").GetHumanishName();

            NUnit.Framework.Assert.AreEqual("c", humanishName);
        }
예제 #30
0
 /// <exception cref="System.NotSupportedException"></exception>
 /// <exception cref="NGit.Errors.TransportException"></exception>
 public override NGit.Transport.Transport Open(URIish uri, Repository local, string
                                               remoteName)
 {
     throw new NotSupportedException("not supported");
 }
예제 #31
0
 /// <summary>Open (or reuse) a session to a host.</summary>
 /// <remarks>
 /// Open (or reuse) a session to a host.
 /// <p>
 /// A reasonable UserInfo that can interact with the end-user (if necessary)
 /// is installed on the returned session by this method.
 /// <p>
 /// The caller must connect the session by invoking <code>connect()</code>
 /// if it has not already been connected.
 /// </remarks>
 /// <param name="uri">URI information about the remote host</param>
 /// <param name="credentialsProvider">provider to support authentication, may be null.
 ///     </param>
 /// <param name="fs">
 /// the file system abstraction which will be necessary to
 /// perform certain file system operations.
 /// </param>
 /// <param name="tms">Timeout value, in milliseconds.</param>
 /// <returns>a session that can contact the remote host.</returns>
 /// <exception cref="NGit.Errors.TransportException">the session could not be created.
 ///     </exception>
 public abstract RemoteSession GetSession(URIish uri, CredentialsProvider credentialsProvider
                                          , FS fs, int tms);
예제 #32
0
 protected SpiTransport(Repository local, URIish uri) : base(local, uri)
 {
 }
예제 #33
0
파일: URIishTest.cs 프로젝트: ashmind/ngit
        public virtual void TestGetValidHumanishName()
        {
            string humanishName = new URIish(GIT_SCHEME + "abc").GetHumanishName();

            NUnit.Framework.Assert.AreEqual("abc", humanishName);
        }
 public _TransportLocal_209(ReceivePackRefFilterTest _enclosing, Repository baseArg1
                            , URIish baseArg2, FilePath baseArg3) : base(baseArg1, baseArg2, baseArg3)
 {
     this._enclosing = _enclosing;
 }
예제 #35
0
 internal TransportLocal(Repository local, URIish uri, FilePath gitDir) : base(local
                                                                               , uri)
 {
     remoteGitDir = gitDir;
 }
예제 #36
0
		/// <summary>Create a new transport instance.</summary>
		/// <remarks>Create a new transport instance.</remarks>
		/// <param name="local">
		/// the repository this instance will fetch into, or push out of.
		/// This must be the repository passed to
		/// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
		/// 	</see>
		/// .
		/// </param>
		/// <param name="uri">
		/// the URI used to access the remote repository. This must be the
		/// URI passed to
		/// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
		/// 	</see>
		/// .
		/// </param>
		protected internal HttpTransport(Repository local, URIish uri) : base(local, uri)
		{
		}
예제 #37
0
 /// <summary>Reset the credentials provider for the given URI</summary>
 /// <param name="uri"></param>
 public virtual void Reset(URIish uri)
 {
 }
예제 #38
0
            /// <exception cref="NGit.Errors.NoRemoteRepositoryException"></exception>
            public override NGit.Transport.Transport Open(URIish uri, Repository local, string
				 remoteName)
            {
                // If the reference is to a local file, C Git behavior says
                // assume this is a bundle, since repositories are directories.
                //
                FilePath path = local.FileSystem.Resolve(new FilePath("."), uri.GetPath());
                if (path.IsFile())
                {
                    return new TransportBundleFile(local, uri, path);
                }
                FilePath gitDir = RepositoryCache.FileKey.Resolve(path, local.FileSystem);
                if (gitDir == null)
                {
                    throw new NoRemoteRepositoryException(uri, JGitText.Get().notFound);
                }
                return new NGit.Transport.TransportLocal(local, uri, gitDir);
            }
예제 #39
0
 /// <summary>Ask for the credential items to be populated.</summary>
 /// <remarks>Ask for the credential items to be populated.</remarks>
 /// <param name="uri">the URI of the remote resource that needs authentication.</param>
 /// <param name="items">the items the application requires to complete authentication.
 ///     </param>
 /// <returns>
 ///
 /// <code>true</code>
 /// if the request was successful and values were
 /// supplied;
 /// <code>false</code>
 /// if the user canceled the request and did
 /// not supply all requested values.
 /// </returns>
 /// <exception cref="NGit.Errors.UnsupportedCredentialItem">if one of the items supplied is not supported.
 ///     </exception>
 public abstract bool Get(URIish uri, params CredentialItem[] items);
예제 #40
0
		/// <summary>
		/// Constructs an PackProtocolException with the specified detail message
		/// prefixed with provided URI.
		/// </summary>
		/// <remarks>
		/// Constructs an PackProtocolException with the specified detail message
		/// prefixed with provided URI.
		/// </remarks>
		/// <param name="uri">URI used for transport</param>
		/// <param name="s">message</param>
		/// <param name="cause">root cause exception</param>
		public PackProtocolException(URIish uri, string s, Exception cause) : this(uri + 
			": " + s, cause)
		{
		}
예제 #41
0
        public override Transport Open(URIish uri, Repository local, string remoteName)
        {
            var transport = _outerProtocol.Open(uri, local, remoteName);

            // Replace the session factory when we've got an SshTransport.

            var sshTransport = transport as SshTransport;

            if (sshTransport != null)
                sshTransport.SetSshSessionFactory(SshSessionFactory.Instance);

            var currentCredentialsProvider = CredentialsProviderScope.Current;

            if (currentCredentialsProvider != null)
                transport.SetCredentialsProvider(currentCredentialsProvider);

            return transport;
        }
		/// <exception cref="NGit.Errors.UnsupportedCredentialItem"></exception>
		public override bool Get(URIish uri, params CredentialItem[] items)
		{
			foreach (CredentialItem i in items)
			{
				if (i is CredentialItem.Username)
				{
					((CredentialItem.Username)i).SetValue(username);
					continue;
				}
				if (i is CredentialItem.Password)
				{
					((CredentialItem.Password)i).SetValue(password);
					continue;
				}
				if (i is CredentialItem.StringType)
				{
					if (i.GetPromptText().Equals("Password: "******":" + i.GetPromptText
					());
			}
			return true;
		}
예제 #43
0
파일: Transport.cs 프로젝트: kenji-tan/ngit
 /// <summary>Open a new transport instance to connect two repositories.</summary>
 /// <remarks>Open a new transport instance to connect two repositories.</remarks>
 /// <param name="local">existing local repository.</param>
 /// <param name="uri">location of the remote repository.</param>
 /// <returns>the new transport instance. Never null.</returns>
 /// <exception cref="System.NotSupportedException">the protocol specified is not supported.
 /// 	</exception>
 /// <exception cref="NGit.Errors.TransportException">the transport cannot open this URI.
 /// 	</exception>
 public static NGit.Transport.Transport Open(Repository local, URIish uri)
 {
     return Open(local, uri, null);
 }
예제 #44
0
			/// <exception cref="System.NotSupportedException"></exception>
			public override NGit.Transport.Transport Open(URIish uri, Repository local, string
				 remoteName)
			{
				return new NGit.Transport.TransportGitSsh(local, uri);
			}
			public _TransportLocal_210(ReceivePackAdvertiseRefsHookTest _enclosing, Repository
				 baseArg1, URIish baseArg2, FilePath baseArg3) : base(baseArg1, baseArg2, baseArg3
				)
			{
				this._enclosing = _enclosing;
			}
예제 #46
0
 /// <summary>Create a minimal HTTP transport instance not tied to a single repository.
 ///     </summary>
 /// <remarks>Create a minimal HTTP transport instance not tied to a single repository.
 ///     </remarks>
 /// <param name="uri"></param>
 protected internal HttpTransport(URIish uri) : base(uri)
 {
 }
예제 #47
0
        internal TransportLocal(Repository local, URIish uri, FilePath gitDir)
            : base(local
			, uri)
        {
            remoteGitDir = gitDir;
        }
예제 #48
0
 /// <exception cref="System.NotSupportedException"></exception>
 public override NGit.Transport.Transport Open(URIish uri)
 {
     return(new NGit.Transport.TransportHttp(uri));
 }
예제 #49
0
		/// <summary>
		/// Constructs an PackProtocolException with the specified detail message
		/// prefixed with provided URI.
		/// </summary>
		/// <remarks>
		/// Constructs an PackProtocolException with the specified detail message
		/// prefixed with provided URI.
		/// </remarks>
		/// <param name="uri">URI used for transport</param>
		/// <param name="s">message</param>
		public PackProtocolException(URIish uri, string s) : base(uri + ": " + s)
		{
		}
 /// <summary>Create a new transport instance.</summary>
 /// <remarks>Create a new transport instance.</remarks>
 /// <param name="local">
 /// the repository this instance will fetch into, or push out of.
 /// This must be the repository passed to
 /// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
 ///     </see>
 /// .
 /// </param>
 /// <param name="uri">
 /// the URI used to access the remote repository. This must be the
 /// URI passed to
 /// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
 ///     </see>
 /// .
 /// </param>
 protected internal SshTransport(Repository local, URIish uri) : base(local, uri)
 {
     sch = SshSessionFactory.GetInstance();
 }
예제 #51
0
		/// <summary>Create a new transport instance.</summary>
		/// <remarks>Create a new transport instance.</remarks>
		/// <param name="local">
		/// the repository this instance will fetch into, or push out of.
		/// This must be the repository passed to
		/// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
		/// 	</see>
		/// .
		/// </param>
		/// <param name="uri">
		/// the URI used to access the remote repository. This must be the
		/// URI passed to
		/// <see cref="Transport.Open(NGit.Repository, URIish)">Transport.Open(NGit.Repository, URIish)
		/// 	</see>
		/// .
		/// </param>
		protected internal SshTransport(Repository local, URIish uri) : base(local, uri)
		{
			sch = SshSessionFactory.GetInstance();
		}
예제 #52
0
 public MockTransport(PushProcessTest _enclosing, Repository local, URIish uri)
     : base(local, uri)
 {
     this._enclosing = _enclosing;
 }
예제 #53
0
			public override bool CanHandle(URIish uri, Repository local, string remoteName)
			{
				if (uri.GetScheme() == null)
				{
					// scp-style URI "host:path" does not have scheme.
					return uri.GetHost() != null && uri.GetPath() != null && uri.GetHost().Length != 
						0 && uri.GetPath().Length != 0;
				}
				return base.CanHandle(uri, local, remoteName);
			}
예제 #54
0
 /// <exception cref="System.NotSupportedException"></exception>
 public override NGit.Transport.Transport Open(URIish uri, Repository local, string
                                               remoteName)
 {
     return(new NGit.Transport.TransportHttp(local, uri));
 }
예제 #55
0
		protected internal TransportGitSsh(Repository local, URIish uri) : base(local, uri
			)
		{
			if (UseExtSession())
			{
				SetSshSessionFactory(new _SshSessionFactory_134(this));
			}
		}
 internal BasePackConnection(PackTransport packTransport)
 {
     transport = (NGit.Transport.Transport)packTransport;
     local     = transport.local;
     uri       = transport.uri;
 }
예제 #57
0
		internal BasePackConnection(PackTransport packTransport)
		{
			transport = (NGit.Transport.Transport)packTransport;
			local = transport.local;
			uri = transport.uri;
		}
예제 #58
0
        public virtual void TestGetSlashValidSlashDotGitSlashHumanishName()
        {
            string humanishName = new URIish("/abc/.git").GetHumanishName();

            NUnit.Framework.Assert.AreEqual("abc", humanishName);
        }