示例#1
0
        private int Run(string remoteId)
        {
            var tfsRemote = _globals.Repository.ReadTfsRemote(remoteId);

            if (tfsRemote == null)
            {
                throw new GitTfsException("error: No git-tfs repository found. Please try to clone first...\n");
            }

            _authors.Parse(AuthorsFilePath, _globals.GitDir);

            return(CreateLabelsForTfsBranch(tfsRemote));
        }
示例#2
0
        private IGitTfsRemote InitFromDefaultRemote()
        {
            var defaultRemote = _globals.Repository.ReadTfsRemote(GitTfsConstants.DefaultRepositoryId);

            if (defaultRemote == null)
            {
                throw new GitTfsException("error: No git-tfs repository found. Please try to clone first...\n");
            }

            _remoteOptions = new RemoteOptions();
            if (!string.IsNullOrWhiteSpace(TfsUsername))
            {
                _remoteOptions.Username = TfsUsername;
                _remoteOptions.Password = TfsPassword;
            }
            else
            {
                _remoteOptions.Username = defaultRemote.TfsUsername;
                _remoteOptions.Password = defaultRemote.TfsPassword;
            }

            _authors.Parse(AuthorsFilePath, _globals.GitDir);

            return(defaultRemote);
        }
示例#3
0
        public void AuthorsFileTestBadRecord()
        {
            string author =
                @"Domain\Test.User = Test User";
            AuthorsFile authFile = new AuthorsFile();

            Assert.Throws <GitTfsException>(() => authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author)))));
        }
示例#4
0
        private AuthorsFile _SetupAuthorsFile(string[] authors)
        {
            string author = _MergeAuthorsIntoString(authors);

            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(author))));
            return(authFile);
        }
示例#5
0
        public void AuthorsFileMultiLineRecordWithBlankLine()
        {
            string author =
                @"Domain\Test.User = Test User <*****@*****.**>

Domain\Different.User = Three Name User < *****@*****.** >";
            AuthorsFile authFile = new AuthorsFile();

            Assert.Throws <GitTfsException>(() => authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author)))));
        }
示例#6
0
        public void AuthorsFileEmptyFile()
        {
            MemoryStream ms       = new MemoryStream();
            StreamReader sr       = new StreamReader(ms);
            AuthorsFile  authFile = new AuthorsFile();

            authFile.Parse(sr);
            Assert.NotNull(authFile.Authors);
            Assert.Equal <int>(0, authFile.Authors.Count);
        }
示例#7
0
文件: Fetch.cs 项目: irontoby/git-tfs
        private int Run(bool stopOnFailMergeCommit, params string[] args)
        {
            authors.Parse(AuthorsFilePath, globals.GitDir);

            foreach (var remote in GetRemotesToFetch(args))
            {
                FetchRemote(stopOnFailMergeCommit, remote);
            }
            return(0);
        }
示例#8
0
        public void AuthorsFileInternationalCharactersCommented()
        {
            string      author   = @"DOMAIN\Blåbærsyltetøy = ÆØÅ User <ÆØÅ@example.com>
#DifferentDomain\Blåbærsyltetøy = ÆØÅ User <ÆØÅ@example.com>";
            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(author))));
            Assert.NotNull(authFile.Authors);
            Assert.Equal <int>(1, authFile.Authors.Count);
            Assert.True(authFile.Authors.ContainsKey(@"domain\Blåbærsyltetøy"));
        }
示例#9
0
        // uses rebase and works only with HEAD in a none bare repository
        public int Run(string localBranch)
        {
            _globals.WarnOnGitVersion(_stdout);

            if (!_globals.Repository.IsBare)
            {
                throw new GitTfsException("error: This syntax with one parameter is only allowed in bare repository.");
            }

            _authors.Parse(null, _globals.GitDir);

            return(_writer.Write(GitRepository.ShortToLocalName(localBranch), PerformRCheckin));
        }
示例#10
0
        public void AuthorsFileCaseInsensitiveRecord()
        {
            string      author   = @"DOMAIN\Test.User = Test User <*****@*****.**>";
            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author))));
            Assert.NotNull(authFile.Authors);
            Assert.Equal <int>(1, authFile.Authors.Count);
            Assert.True(authFile.Authors.ContainsKey(@"domain\Test.User"));
            Author auth = authFile.Authors[@"domain\Test.User"];

            Assert.Equal <string>("Test User", auth.Name);
            Assert.Equal <string>("*****@*****.**", auth.Email);
        }
示例#11
0
        public void AuthorsFileCommentCharacterMiddleOfLine()
        {
            string author =
                @"Domain\Test.User = Test User <*****@*****.**>
D#omain\Different.User = Three Name User < *****@*****.** >";
            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author))));
            Assert.NotNull(authFile.Authors);
            Assert.Equal <int>(2, authFile.Authors.Count);

            Assert.True(authFile.Authors.ContainsKey(@"Domain\Test.User"));
            Assert.True(authFile.Authors.ContainsKey(@"D#omain\Different.User"));
        }
示例#12
0
        public void AuthorsFileSimpleRecord()
        {
            string      author   = @"Domain\Test.User = Test User <*****@*****.**>";
            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author))));
            Assert.NotNull(authFile.Authors);
            Assert.Single(authFile.Authors);
            Assert.True(authFile.Authors.ContainsKey(@"Domain\Test.User"));
            Author auth = authFile.Authors[@"Domain\Test.User"];

            Assert.Equal("Test User", auth.Name);
            Assert.Equal("*****@*****.**", auth.Email);
        }
示例#13
0
        public void AuthorsFileInternationalCharacters()
        {
            string      author   = @"DOMAIN\Blåbærsyltetøy = ÆØÅ User <ÆØÅ@example.com>";
            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.UTF8.GetBytes(author))));
            Assert.NotNull(authFile.Authors);
            Assert.Single(authFile.Authors);
            Assert.True(authFile.Authors.ContainsKey(@"domain\Blåbærsyltetøy"));
            Author auth = authFile.Authors[@"domain\Blåbærsyltetøy"];

            Assert.Equal("ÆØÅ User", auth.Name);
            Assert.Equal("ÆØÅ@example.com", auth.Email);
        }
示例#14
0
        public int Run(params string[] args)
        {
            authors.Parse(AuthorsFilePath, globals.GitDir);

            foreach (var remote in GetRemotesToFetch(args))
            {
                Trace.WriteLine("Fetching from TFS remote " + remote.Id);
                DoFetch(remote);
                if (labels != null && FetchLabels)
                {
                    Trace.WriteLine("Fetching labels from TFS remote " + remote.Id);
                    labels.Run(remote);
                }
            }
            return(0);
        }
示例#15
0
        public void AuthorsFileMultiLineRecord()
        {
            string author =
                @"Domain\Test.User = Test User <*****@*****.**>
Domain\Different.User = Three Name User < *****@*****.** >";
            AuthorsFile authFile = new AuthorsFile();

            authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author))));
            Assert.NotNull(authFile.Authors);
            Assert.Equal <int>(2, authFile.Authors.Count);

            Assert.True(authFile.Authors.ContainsKey(@"Domain\Test.User"));
            Author auth = authFile.Authors[@"Domain\Test.User"];

            Assert.Equal <string>("Test User", auth.Name);
            Assert.Equal <string>("*****@*****.**", auth.Email);

            Assert.True(authFile.Authors.ContainsKey(@"Domain\Different.User"));
            auth = authFile.Authors[@"Domain\Different.User"];
            Assert.Equal <string>("Three Name User", auth.Name);
            Assert.Equal <string>(" [email protected] ", auth.Email);
        }