This URI like construct used for referencing Git archives over the net, as well as locally stored archives. The most important difference compared to RFC 2396 URI's is that no URI encoding/decoding ever takes place. A space or any special character is written as-is.
예제 #1
0
 public WalkPushConnection(IWalkTransport walkTransport, WalkRemoteObjectDatabase w)
 {
     var t = (Transport) walkTransport;
     _local = t.Local;
     _uri = t.Uri;
     _dest = w;
 }
예제 #2
0
        public static bool canHandle(URIish uri)
        {
            if (uri == null)
                throw new ArgumentNullException("uri");
            if (!uri.IsRemote)
            {
                return false;
            }

            string scheme = uri.Scheme;

            if ("ssh".Equals(scheme))
            {
                return true;
            }

            if ("ssh+git".Equals(scheme))
            {
                return true;
            }

            if ("git+ssh".Equals(scheme))
            {
                return true;
            }

            if (scheme == null && uri.Host != null && uri.Path != null)
            {
                return true;
            }

            return false;
        }
예제 #3
0
 public FetchHeadRecord(ObjectId newValue, bool notForMerge, string sourceName, URIish sourceUri)
 {
     NewValue = newValue;
     NotForMerge = notForMerge;
     SourceName = sourceName;
     SourceURI = sourceUri;
 }
예제 #4
0
        public static bool canHandle(URIish uri)
        {
            if (uri == null)
                throw new ArgumentNullException ("uri");

            return uri.IsRemote && "sftp".Equals(uri.Scheme);
        }
예제 #5
0
        public static bool canHandle(URIish uri)
        {
            if (uri == null)
                throw new System.ArgumentNullException("uri");

            return "git".Equals(uri.Scheme);
        }
예제 #6
0
        public static bool canHandle(URIish uri)
        {
            if (!uri.IsRemote)
            {
                return false;
            }

            string scheme = uri.Scheme;

            if ("ssh".Equals(scheme))
            {
                return true;
            }

            if ("ssh+git".Equals(scheme))
            {
                return true;
            }

            if ("git+ssh".Equals(scheme))
            {
                return true;
            }

            if (scheme == null && uri.Host != null && uri.Path != null)
            {
                return true;
            }

            return false;
        }
예제 #7
0
 public SubmoduleEntry(string name, string path, URIish url, UpdateMethod update)
 {
     Name = name;
     Path = path;
     Url = url;
     Update = update;
 }
예제 #8
0
        public static bool canHandle(URIish uri)
        {
            if (!uri.IsRemote)
            {
                return false;
            }

            return S3_SCHEME == uri.Scheme;
        }
예제 #9
0
 public void testFileProtoWindows()
 {
     const string str = "file:///D:/m y";
     var u = new URIish(str);
     Assert.AreEqual("file", u.Scheme);
     Assert.IsFalse(u.IsRemote);
     Assert.AreEqual("D:/m y", u.Path);
     Assert.AreEqual(str, u.ToString());
     Assert.AreEqual(u, new URIish(str));
 }
예제 #10
0
 public void testUnixFile()
 {
     const string str = "/home/m y";
     var u = new URIish(str);
     Assert.IsNull(u.Scheme);
     Assert.IsFalse(u.IsRemote);
     Assert.AreEqual(str, u.Path);
     Assert.AreEqual(str, u.ToString());
     Assert.AreEqual(u, new URIish(str));
 }
예제 #11
0
 public void testWindowsFile2()
 {
     const string str = "D:\\m y";
     var u = new URIish(str);
     Assert.IsNull(u.Scheme);
     Assert.IsFalse(u.IsRemote);
     Assert.AreEqual("D:/m y", u.Path);
     Assert.AreEqual("D:/m y", u.ToString());
     Assert.AreEqual(u, new URIish(str));
 }
예제 #12
0
        public TransportLocal(Repository local, URIish uri)
            : base(local, uri)
        {
            string dir = FS.resolve(new DirectoryInfo(PWD), uri.Path).FullName;
            if(Directory.Exists(Path.Combine(dir, Constants.DOT_GIT)))
            {
                dir = Path.Combine(dir, Constants.DOT_GIT);
            }

            remoteGitDir = new DirectoryInfo(dir);
        }
예제 #13
0
 public void testGitProtoUnix()
 {
     const string str = "git://example.com/home/m y";
     var u = new URIish(str);
     Assert.AreEqual("git", u.Scheme);
     Assert.IsTrue(u.IsRemote);
     Assert.AreEqual("example.com", u.Host);
     Assert.AreEqual("/home/m y", u.Path);
     Assert.AreEqual(str, u.ToString());
     Assert.AreEqual(u, new URIish(str));
 }
예제 #14
0
        public static bool canHandle(URIish uri)
        {
            if (uri == null)
                throw new ArgumentNullException("uri");

            if (!uri.IsRemote)
            {
                return false;
            }
            string s = uri.Scheme;
            return "http".Equals(s) || "https".Equals(s) || "ftp".Equals(s);
        }
예제 #15
0
	    public static bool canHandle(URIish uri)
        {
			if (uri == null)
				throw new ArgumentNullException ("uri");
			
		    if (!uri.IsRemote)
		    {
		        return false;
		    }

		    return S3_SCHEME == uri.Scheme;
	    }
예제 #16
0
        public static bool canHandle(URIish uri)
        {
            if (uri.Host != null || uri.Port > 0 || uri.User != null || uri.Pass != null || uri.Path == null)
            {
                return false;
            }

            if ("file".Equals(uri.Scheme) || uri.Scheme == null)
            {
                return FS.resolve(new DirectoryInfo(PWD), uri.Path).Exists;
            }

            return false;
        }
예제 #17
0
        public static bool CanHandle(URIish uri)
        {
            if (uri == null)
                throw new ArgumentNullException ("uri");
            if (uri.Host != null || uri.Port > 0 || uri.User != null || uri.Pass != null || uri.Path == null)
                return false;

            if ("file".Equals(uri.Scheme) || uri.Scheme == null)
            {
                FileInfo file = resolve(new DirectoryInfo("."), uri.Path);
                return file.Name.EndsWith(".bundle");
            }

            return false;
        }
예제 #18
0
        public void testAddURI()
        {
            readConfig(string.Empty);

            URIish uri = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.AreEqual(0, rc.URIs.Count);

            Assert.IsTrue(rc.AddURI(uri));
            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(uri, rc.URIs[0]);

            Assert.IsFalse(rc.AddURI(new URIish(uri.ToString())));
            Assert.AreEqual(1, rc.URIs.Count);
        }
예제 #19
0
 public TransportHttp(Repository local, URIish uri)
     : base(local, uri)
 {
     try
     {
         string uriString = uri.ToString();
         if (!uriString.EndsWith("/"))
         {
             uriString += "/";
         }
         _baseUrl = new Uri(uriString);
         _objectsUrl = new Uri(_baseUrl, "objects/");
     }
     catch (UriFormatException e)
     {
         throw new NotSupportedException("Invalid URL " + uri, e);
     }
 }
예제 #20
0
        public void testRemoveOnlyURI()
        {
            readConfig(string.Empty);

            URIish a = new URIish("/some/dir");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.IsTrue(rc.AddURI(a));

            Assert.AreEqual(1, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);

            Assert.IsTrue(rc.RemoveURI(a));
            Assert.AreEqual(0, rc.URIs.Count);
        }
예제 #21
0
        public void testRemoveMiddleURI()
        {
            readConfig(string.Empty);

            URIish a = new URIish("/some/dir");
            URIish b = new URIish("/another/dir");
            URIish c = new URIish("/more/dirs");
            RemoteConfig rc = new RemoteConfig(config, "backup");
            Assert.IsTrue(rc.AddURI(a));
            Assert.IsTrue(rc.AddURI(b));
            Assert.IsTrue(rc.AddURI(c));

            Assert.AreEqual(3, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(b, rc.URIs[1]);
            Assert.AreEqual(c, rc.URIs[2]);

            Assert.IsTrue(rc.RemoveURI(b));
            Assert.AreEqual(2, rc.URIs.Count);
            Assert.AreSame(a, rc.URIs[0]);
            Assert.AreSame(c, rc.URIs[1]);
        }
예제 #22
0
 public TransportGitAnon(Repository local, URIish uri)
     : base(local, uri)
 {
 }
예제 #23
0
 public TransportAmazonS3(Repository local, URIish uri) : base(local, uri)
 {
 }
예제 #24
0
 protected SshTransport(Repository local, URIish uri)
     : base(local, uri)
 {
     _sch = SshSessionFactory.Instance;
 }
예제 #25
0
        /// <summary>
        /// Support for Transport over HTTP and Git (Anon+SSH)
        /// </summary>
        /// <param name="local"></param>
        /// <param name="remote"></param>
        /// <returns></returns>
        public static Transport Open(Repository local, URIish remote)
        {
            if (TransportHttp.canHandle(remote))
                return new TransportHttp(local, remote);

            if (TransportGitAnon.canHandle(remote))
                return new TransportGitAnon(local, remote);

            if (TransportGitSsh.canHandle(remote))
                return new TransportGitSsh(local, remote);

            if (TransportSftp.canHandle(remote))
                return new TransportSftp(local, remote);

            throw new NotSupportedException("URI not supported: " + remote);
        }
예제 #26
0
파일: URIish.cs 프로젝트: dev218/GitSharp
		private URIish(URIish u)
		{
			Scheme = u.Scheme;
			Path = u.Path;
			User = u.User;
			Pass = u.Pass;
			Port = u.Port;
			Host = u.Host;
		}
예제 #27
0
 public void SetAdvertisedRefs(URIish u, IDictionary <string, Ref> ar)
 {
     _uri            = u;
     _advertisedRefs = ar;
 }
예제 #28
0
 public TransportLocal(Repository local, URIish uri) : base(local, uri)
 {
 }
예제 #29
0
        private void printPushResult(URIish uri, PushResult result)
        {
            shownUri = false;
            bool everythingUpToDate = true;

            foreach (RemoteRefUpdate rru in result.RemoteUpdates)
            {
                if (rru.Status == RemoteRefUpdate.UpdateStatus.UP_TO_DATE)
                {
                    if (Verbose)
                        printRefUpdateResult(uri, result, rru);
                }
                else
                {
                    everythingUpToDate = false;
                }
            }

            foreach (RemoteRefUpdate rru in result.RemoteUpdates)
            {
                if (rru.Status == RemoteRefUpdate.UpdateStatus.OK)
                    printRefUpdateResult(uri, result, rru);
            }

            foreach (RemoteRefUpdate rru in result.RemoteUpdates)
            {
                if (rru.Status != RemoteRefUpdate.UpdateStatus.OK && rru.Status != RemoteRefUpdate.UpdateStatus.UP_TO_DATE)
                    printRefUpdateResult(uri, result, rru);
            }

            if (everythingUpToDate)
                OutputStream.WriteLine("Everything up-to-date");
        }
예제 #30
0
 protected BasePackConnection(IPackTransport packTransport)
 {
     transport = (Transport)packTransport;
     local     = transport.Local;
     uri       = transport.Uri;
 }
예제 #31
0
 public TransportGitSsh(Repository local, URIish uri)
     : base(local, uri)
 {
 }
예제 #32
0
 public static bool canHandle(URIish uri)
 {
     return("git".Equals(uri.Scheme));
 }
예제 #33
0
        /// <summary>
        /// Add a new push-only URI to the end of the list of URIs.
        /// </summary>
        /// <param name="toAdd">the new URI to add to this remote.</param>
        /// <returns>true if the URI was added; false if it already exists.</returns>
		public bool AddPushURI(URIish toAdd)
		{
			if (PushURIs.Contains(toAdd)) return false;

			PushURIs.Add(toAdd);
			return true;
		}
예제 #34
0
        protected Transport(Repository local, URIish uri)
        {
            _optionUploadPack = RemoteConfig.DEFAULT_UPLOAD_PACK;
            _optionReceivePack = RemoteConfig.DEFAULT_RECEIVE_PACK;
            FetchThin = DEFAULT_FETCH_THIN;
            PushThin = DEFAULT_PUSH_THIN;
            _tagopt = TagOpt.NO_TAGS;
            _fetchSpecs = new List<RefSpec>();
            _pushSpecs = new List<RefSpec>();

            _local = local;
            _uri = uri;
        }
예제 #35
0
 /// <summary>
 /// Remove a push-only URI from the list of URIs.
 /// </summary>
 /// <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 bool RemovePushURI(URIish toRemove)
 {
     return(PushURIs.Remove(toRemove));
 }
예제 #36
0
        /// <summary>
        /// Remove a URI from the list of URIs.
        /// </summary>
        /// <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 bool RemoveURI(URIish toRemove)
		{
			return URIs.Remove(toRemove);
		}
 /// <summary>
 /// Create a new transport to fetch objects from a streamed bundle.
 /// <para/>
 /// 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).
 /// <para/>
 /// 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.
 /// </summary>
 /// <param name="local">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="inputStream">the stream to Read the bundle from.</param>
 public TransportBundleStream(Repository local, URIish uri, Stream inputStream)
     : base(local, uri)
 {
     _inputStream = inputStream;
 }
예제 #38
0
 /// <summary>
 /// Remove a push-only URI from the list of URIs.
 /// </summary>
 /// <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 bool RemovePushURI(URIish toRemove)
 {
     return PushURIs.Remove(toRemove);
 }
예제 #39
0
 public FetchHeadRecord(ObjectId newValue, bool notForMerge, string sourceName, URIish sourceUri)
 {
     NewValue    = newValue;
     NotForMerge = notForMerge;
     SourceName  = sourceName;
     SourceURI   = sourceUri;
 }
예제 #40
0
        private void printRefUpdateResult(URIish uri, OperationResult result, RemoteRefUpdate rru)
        {
            if (!shownUri)
            {
                shownUri = true;
                OutputStream.WriteLine("To " + uri);
            }

            string remoteName = rru.RemoteName;
            string srcRef = rru.IsDelete ? null : rru.SourceRef;

            switch (rru.Status)
            {
                case RemoteRefUpdate.UpdateStatus.OK:
                    {
                        if (rru.IsDelete)
                            printUpdateLine('-', "[deleted]", null, remoteName, null);
                        else
                        {
                            GitSharp.Core.Ref oldRef = result.GetAdvertisedRef(remoteName);
                            if (oldRef == null)
                            {
                                string summary = remoteName.StartsWith(Constants.R_TAGS) ? "[new tag]" : "[new branch]";
                                printUpdateLine('*', summary, srcRef, remoteName, null);
                            }
                            else
                            {
                                bool fastForward = rru.FastForward;
                                char flag = fastForward ? ' ' : '+';
                                string summary = oldRef.ObjectId.Abbreviate(Repository._internal_repo).name() +
                                                 (fastForward ? ".." : "...") +
                                                 rru.NewObjectId.Abbreviate(Repository._internal_repo).name();
                                string message = fastForward ? null : "forced update";
                                printUpdateLine(flag, summary, srcRef, remoteName, message);
                            }
                        }
                        break;
                    }

                case RemoteRefUpdate.UpdateStatus.NON_EXISTING:
                    printUpdateLine('X', "[no match]", null, remoteName, null);
                    break;

                case RemoteRefUpdate.UpdateStatus.REJECTED_NODELETE:
                    printUpdateLine('!', "[rejected]", null, remoteName, "remote side does not support deleting refs");
                    break;

                case RemoteRefUpdate.UpdateStatus.REJECTED_NONFASTFORWARD:
                    printUpdateLine('!', "[rejected]", srcRef, remoteName, "non-fast forward");
                    break;

                case RemoteRefUpdate.UpdateStatus.REJECTED_REMOTE_CHANGED:
                    {
                        string message = "remote ref object changed - is not expected one " +
                                         rru.ExpectedOldObjectId.Abbreviate(Repository._internal_repo).name();
                        printUpdateLine('!', "[rejected]", srcRef, remoteName, message);
                        break;
                    }

                case RemoteRefUpdate.UpdateStatus.REJECTED_OTHER_REASON:
                    printUpdateLine('!', "[rejected]", srcRef, remoteName, rru.Message);
                    break;

                case RemoteRefUpdate.UpdateStatus.UP_TO_DATE:
                    if (Verbose)
                        printUpdateLine('=', "[up to date]", srcRef, remoteName, null);
                    break;

                case RemoteRefUpdate.UpdateStatus.NOT_ATTEMPTED:
                case RemoteRefUpdate.UpdateStatus.AWAITING_REPORT:
                    printUpdateLine('?', "[unexpected push-process behavior]", srcRef, remoteName, rru.Message);
                    break;
            }
        }
 public TransportBundleFile(Repository local, URIish uri)
     : base(local, uri)
 {
     _bundle = PathUtil.CombineFilePath(new DirectoryInfo("."), uri.Path);
 }