Exemple #1
0
        public IGitTfsRemote CreateTfsRemote(RemoteInfo remote)
        {
            if (HasRemote(remote.Id))
            {
                throw new GitTfsException("A remote with id \"" + remote.Id + "\" already exists.");
            }

            // These help the new (if it's new) git repository to behave more sanely.
            _repository.Config.Set("core.autocrlf", "false");
            _repository.Config.Set("core.ignorecase", "false");

            foreach (var entry in _remoteConfigReader.Dump(remote))
            {
                if (entry.Value != null)
                {
                    _repository.Config.Set(entry.Key, entry.Value);
                }
                else
                {
                    _repository.Config.Unset(entry.Key);
                }
            }

            var gitTfsRemote = BuildRemote(remote);

            gitTfsRemote.EnsureTfsAuthenticated();

            return(_cachedRemotes[remote.Id] = gitTfsRemote);
        }
 public IEnumerable<KeyValuePair<string, string>> Dump(RemoteInfo remote)
 {
     if (!string.IsNullOrWhiteSpace(remote.Id))
     {
         var prefix = "tfs-remote." + remote.Id + ".";
         yield return c(prefix + "url", remote.Url);
         yield return c(prefix + "repository", remote.Repository);
         yield return c(prefix + "username", remote.Username);
         yield return c(prefix + "password", remote.Password);
         yield return c(prefix + "ignore-paths", remote.IgnoreRegex);
         yield return c(prefix + "legacy-urls", remote.Aliases == null ? null : string.Join(",", remote.Aliases));
         yield return c(prefix + "autotag", remote.Autotag ? "true" : null);
     }
 }
Exemple #3
0
 private GitTfsRemote BuildRemote(string repository, string url = "", string[] legacyUrls = null)
 {
     if (legacyUrls == null)
         legacyUrls = new string[0];
     var info = new RemoteInfo
     {
         Url = url,
         Repository = repository,
         Aliases = legacyUrls,
     };
     var mocks = new RhinoAutoMocker<GitTfsRemote>();
     mocks.Inject<TextWriter>(new StringWriter());
     mocks.Inject<RemoteInfo>(info);
     mocks.Inject<ITfsHelper>(MockRepository.GenerateStub<ITfsHelper>()); // GitTfsRemote backs the TfsUrl with this.
     return mocks.ClassUnderTest;
 }
Exemple #4
0
        public GitTfsRemote(RemoteInfo info, IGitRepository repository, RemoteOptions remoteOptions, Globals globals, ITfsHelper tfsHelper, TextWriter stdout)
        {
            this.remoteOptions = remoteOptions;
            this.globals = globals;
            this.stdout = stdout;
            Tfs = tfsHelper;
            Repository = repository;

            Id = info.Id;
            TfsUrl = info.Url;
            TfsRepositoryPath = info.Repository;
            TfsUsername = info.Username;
            TfsPassword = info.Password;
            Aliases = (info.Aliases ?? Enumerable.Empty<string>()).ToArray();
            IgnoreRegexExpression = info.IgnoreRegex;
            Autotag = info.Autotag;
        }
Exemple #5
0
        public GitTfsRemote(RemoteInfo info, IGitRepository repository, RemoteOptions remoteOptions, Globals globals, ITfsHelper tfsHelper, TextWriter stdout)
        {
            this.remoteOptions = remoteOptions;
            this.globals       = globals;
            this.stdout        = stdout;
            Tfs        = tfsHelper;
            Repository = repository;

            Id                    = info.Id;
            TfsUrl                = info.Url;
            TfsRepositoryPath     = info.Repository;
            TfsUsername           = info.Username;
            TfsPassword           = info.Password;
            Aliases               = (info.Aliases ?? Enumerable.Empty <string>()).ToArray();
            IgnoreRegexExpression = info.IgnoreRegex;
            Autotag               = info.Autotag;
        }
        public IEnumerable <KeyValuePair <string, string> > Dump(RemoteInfo remote)
        {
            if (!string.IsNullOrWhiteSpace(remote.Id))
            {
                var prefix = "tfs-remote." + remote.Id + ".";
                yield return(c(prefix + "url", remote.Url));

                yield return(c(prefix + "repository", remote.Repository));

                yield return(c(prefix + "username", remote.Username));

                yield return(c(prefix + "password", remote.Password));

                yield return(c(prefix + "ignore-paths", remote.IgnoreRegex));

                yield return(c(prefix + "legacy-urls", remote.Aliases == null ? null : string.Join(",", remote.Aliases)));

                yield return(c(prefix + "autotag", remote.Autotag ? "true" : null));
            }
        }
        public IGitTfsRemote CreateTfsRemote(RemoteInfo remote, string autocrlf = null, string ignorecase = null)
        {
            if (HasRemote(remote.Id))
            {
                throw new GitTfsException("A remote with id \"" + remote.Id + "\" already exists.");
            }

            // The autocrlf default (as indicated by a null) is false and is set to override the system-wide setting.
            // When creating branches we use the empty string to indicate that we do not want to set the value at all.
            if (autocrlf == null)
            {
                autocrlf = "false";
            }
            if (autocrlf != String.Empty)
            {
                _repository.Config.Set("core.autocrlf", autocrlf);
            }

            if (ignorecase != null)
            {
                _repository.Config.Set("core.ignorecase", ignorecase);
            }

            foreach (var entry in _remoteConfigReader.Dump(remote))
            {
                if (entry.Value != null)
                {
                    _repository.Config.Set(entry.Key, entry.Value);
                }
                else
                {
                    _repository.Config.Unset(entry.Key);
                }
            }

            var gitTfsRemote = BuildRemote(remote);

            gitTfsRemote.EnsureTfsAuthenticated();

            return(_cachedRemotes[remote.Id] = gitTfsRemote);
        }
Exemple #8
0
        public GitTfsRemote(RemoteInfo info, IGitRepository repository, RemoteOptions remoteOptions, Globals globals,
                            ITfsHelper tfsHelper, ConfigProperties properties)
        {
            this.remoteOptions = remoteOptions;
            this.globals       = globals;
            this.properties    = properties;
            Tfs        = tfsHelper;
            Repository = repository;

            RemoteInfo                  = info;
            Id                          = info.Id;
            TfsUrl                      = info.Url;
            TfsRepositoryPath           = info.Repository;
            TfsUsername                 = info.Username;
            TfsPassword                 = info.Password;
            Aliases                     = (info.Aliases ?? Enumerable.Empty <string>()).ToArray();
            IgnoreRegexExpression       = info.IgnoreRegex;
            IgnoreExceptRegexExpression = info.IgnoreExceptRegex;

            Autotag = info.Autotag;

            this.IsSubtree = CheckSubtree();
        }
Exemple #9
0
        public GitTfsRemote(RemoteInfo info, IGitRepository repository, RemoteOptions remoteOptions, Globals globals,
            ITfsHelper tfsHelper, ConfigProperties properties)
        {
            _remoteOptions = remoteOptions;
            _globals = globals;
            _properties = properties;
            Tfs = tfsHelper;
            Repository = repository;

            RemoteInfo = info;
            Id = info.Id;
            TfsUrl = info.Url;
            TfsRepositoryPath = info.Repository;
            TfsUsername = info.Username;
            TfsPassword = info.Password;
            Aliases = (info.Aliases ?? Enumerable.Empty<string>()).ToArray();
            IgnoreRegexExpression = info.IgnoreRegex;
            IgnoreExceptRegexExpression = info.IgnoreExceptRegex;

            Autotag = info.Autotag;

            IsSubtree = CheckSubtree();
        }
Exemple #10
0
 private IGitTfsRemote BuildRemote(RemoteInfo remoteInfo)
 {
     return _container.With(remoteInfo).With<IGitRepository>(this).GetInstance<IGitTfsRemote>();
 }
Exemple #11
0
        public IGitTfsRemote CreateTfsRemote(RemoteInfo remote, string autocrlf = null, string ignorecase = null)
        {
            if (HasRemote(remote.Id))
                throw new GitTfsException("A remote with id \"" + remote.Id + "\" already exists.");

            // The autocrlf default (as indicated by a null) is false and is set to override the system-wide setting.
            // When creating branches we use the empty string to indicate that we do not want to set the value at all.
            if (autocrlf == null)
                autocrlf = "false";
            if (autocrlf != String.Empty)
                _repository.Config.Set("core.autocrlf", autocrlf);

            if (ignorecase != null)
                _repository.Config.Set("core.ignorecase", ignorecase);

            foreach (var entry in _remoteConfigReader.Dump(remote))
            {
                if (entry.Value != null)
                {
                    _repository.Config.Set(entry.Key, entry.Value);
                }
                else
                {
                    _repository.Config.Unset(entry.Key);
                }
            }

            var gitTfsRemote = BuildRemote(remote);
            gitTfsRemote.EnsureTfsAuthenticated();

            return _cachedRemotes[remote.Id] = gitTfsRemote;
        }
 private IGitTfsRemote BuildRemote(RemoteInfo remoteInfo)
 {
     return(_container.With(remoteInfo).With <IGitRepository>(this).GetInstance <IGitTfsRemote>());
 }
Exemple #13
0
        public IGitTfsRemote CreateTfsRemote(RemoteInfo remote)
        {
            if (HasRemote(remote.Id))
                throw new GitTfsException("A remote with id \"" + remote.Id + "\" already exists.");

            // These help the new (if it's new) git repository to behave more sanely.
            _repository.Config.Set("core.autocrlf", "false");
            _repository.Config.Set("core.ignorecase", "false");

            foreach (var entry in _remoteConfigReader.Dump(remote))
            {
                if (entry.Value != null)
                {
                    _repository.Config.Set(entry.Key, entry.Value);
                }
                else
                {
                    _repository.Config.Unset(entry.Key);
                }
            }

            return _cachedRemotes[remote.Id] = BuildRemote(remote);
        }
        public IGitTfsRemote CreateTfsRemote(RemoteInfo remote, string autocrlf = null, string ignorecase = null)
        {
            if (HasRemote(remote.Id))
                throw new GitTfsException("A remote with id \"" + remote.Id + "\" already exists.");

            // These help the new (if it's new) git repository to behave more sanely.
            _repository.Config.Set("core.autocrlf", (autocrlf == null)?"false":autocrlf);

            if (ignorecase != null)
                _repository.Config.Set("core.ignorecase", ignorecase);

            foreach (var entry in _remoteConfigReader.Dump(remote))
            {
                if (entry.Value != null)
                {
                    _repository.Config.Set(entry.Key, entry.Value);
                }
                else
                {
                    _repository.Config.Unset(entry.Key);
                }
            }

            var gitTfsRemote = BuildRemote(remote);
            gitTfsRemote.EnsureTfsAuthenticated();

            return _cachedRemotes[remote.Id] = gitTfsRemote;
        }
Exemple #15
0
        private GitTfsRemote BuildSubTreeOwnerRemote(IEnumerable<IGitTfsRemote> remotes)
        {
            var info = new RemoteInfo
            {
                Id = "test",
                Url = null,
                Repository = null,
            };
            var mocks = new RhinoAutoMocker<GitTfsRemote>();
            mocks.Inject(info);
            mocks.Inject(MockRepository.GenerateStub<ITfsHelper>()); // GitTfsRemote backs the TfsUrl with this.

            var mockGitRepository = mocks.Get<IGitRepository>();
            mockGitRepository.Stub(t => t.GetSubtrees(Arg<IGitTfsRemote>.Is.Anything)).Return(remotes);

            mocks.Inject(new Globals() { Repository = mockGitRepository });
            return mocks.ClassUnderTest;
        }