示例#1
1
 public InitBranch(TextWriter stdout, Globals globals, Help helper, AuthorsFile authors)
 {
     _stdout = stdout;
     _globals = globals;
     _helper = helper;
     _authors = authors;
 }
示例#2
0
        private void ProcessAuthor(CheckinOptions checkinOptions, TextWriter writer, GitCommit commit)
        {
            if (checkinOptions.AuthorsFilePath == null)
            {
                writer.WriteLine("Author file was not set.");
                return;
            }

            // get authors file FIXME
            AuthorsFile af = new AuthorsFile();
            TextReader  tr = new StreamReader(checkinOptions.AuthorsFilePath);

            af.Parse(tr);

            Author a = af.FindAuthor(commit.AuthorAndEmail);

            if (a == null)
            {
                checkinOptions.AuthorTfsUserId = null;
                return;
            }

            checkinOptions.AuthorTfsUserId = a.TfsUserId;
            writer.WriteLine("Commit was authored by git user {0} {1} ({2})", a.Name, a.Email, a.TfsUserId);
        }
示例#3
0
文件: Fetch.cs 项目: runt18/git-tfs
 public Fetch(Globals globals, RemoteOptions remoteOptions, AuthorsFile authors, Labels labels)
 {
     this.remoteOptions = remoteOptions;
     this.globals = globals;
     this.authors = authors;
     this.labels = labels;
 }
示例#4
0
 public TfsChangeset(ITfsHelper tfs, IChangeset changeset, AuthorsFile authors)
 {
     _tfs = tfs;
     _changeset = changeset;
     _authors = authors;
     BaseChangesetId = _changeset.Changes.Max(c => c.Item.ChangesetId) - 1;
 }
示例#5
0
 public void TestBadRecord()
 {
     string author =
     @"Domain\Test.User = Test User";
     AuthorsFile authFile = new AuthorsFile();
     authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author))));
 }
示例#6
0
 public TfsChangeset(ITfsHelper tfs, IChangeset changeset, TextWriter stdout, AuthorsFile authors)
 {
     _tfs = tfs;
     _changeset = changeset;
     _stdout = stdout;
     _authors = authors;
 }
示例#7
0
 public Fetch(Globals globals, TextWriter stdout, RemoteOptions remoteOptions, AuthorsFile authors, Labels labels)
 {
     this.globals = globals;
     this.stdout = stdout;
     this.remoteOptions = remoteOptions;
     this.authors = authors;
     this.labels = labels;
 }
示例#8
0
 public Rcheckin(CheckinOptions checkinOptions, TfsWriter writer, Globals globals, AuthorsFile authors)
 {
     _checkinOptions = checkinOptions;
     _checkinOptionsFactory = new CheckinOptionsFactory(globals);
     _writer = writer;
     _globals = globals;
     _authors = authors;
 }
示例#9
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);
 }
示例#10
0
 public Rcheckin(TextWriter stdout, CheckinOptions checkinOptions, TfsWriter writer, Globals globals, AuthorsFile authors)
 {
     _stdout = stdout;
     _checkinOptions = checkinOptions;
     _checkinOptionsFactory = new CommitSpecificCheckinOptionsFactory(_stdout, globals, authors);
     _writer = writer;
     _globals = globals;
     _authors = authors;
 }
        public CheckinOptions BuildCommitSpecificCheckinOptions(CheckinOptions sourceCheckinOptions,
            string commitMessage, GitCommit commit, AuthorsFile authors)
        {
            var customCheckinOptions = BuildCommitSpecificCheckinOptions(sourceCheckinOptions, commitMessage);

            customCheckinOptions.ProcessAuthor(writer, commit, authors);

            return customCheckinOptions;
        }
示例#12
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)))));
        }
示例#13
0
 public Fetch(Globals globals, ConfigProperties properties, TextWriter stdout, RemoteOptions remoteOptions, AuthorsFile authors, Labels labels)
 {
     this.globals = globals;
     this.properties = properties;
     this.stdout = stdout;
     this.remoteOptions = remoteOptions;
     this.authors = authors;
     this.labels = labels;
     this.upToChangeSet = -1;
 }
示例#14
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);
 }
示例#15
0
        public void AuthorsFileCommentCharacterStartOfLine()
        {
            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>(1, authFile.Authors.Count);

            Assert.True(authFile.Authors.ContainsKey(@"Domain\Test.User"));
            Assert.False(authFile.Authors.ContainsKey(@"Domain\Different.User"));
        }
        public static void ProcessAuthor(this CheckinOptions checkinOptions, GitCommit commit, AuthorsFile authors)
        {
            if (!authors.IsParseSuccessfull)
                return;

            Author a = authors.FindAuthor(commit.AuthorAndEmail);
            if (a == null)
            {
                checkinOptions.AuthorTfsUserId = null;
                return;
            }

            checkinOptions.AuthorTfsUserId = a.TfsUserId;
            Trace.TraceInformation("Commit was authored by git user {0} {1} ({2})", a.Name, a.Email, a.TfsUserId);
        }
示例#17
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);
        }
        private void ProcessAuthor(CheckinOptions checkinOptions, TextWriter writer, GitCommit commit)
        {
            // get authors file FIXME
            AuthorsFile af = new AuthorsFile();

            if (!af.Parse(checkinOptions.AuthorsFilePath, globals.GitDir))
            {
                return;
            }

            Author a = af.FindAuthor(commit.AuthorAndEmail);

            if (a == null)
            {
                checkinOptions.AuthorTfsUserId = null;
                return;
            }

            checkinOptions.AuthorTfsUserId = a.TfsUserId;
            writer.WriteLine("Commit was authored by git user {0} {1} ({2})", a.Name, a.Email, a.TfsUserId);
        }
        public static void ProcessAuthor(this CheckinOptions checkinOptions, TextWriter writer, GitCommit commit, AuthorsFile authors)
        {
            if (!authors.IsParseSuccessfull)
            {
                return;
            }

            Author a = authors.FindAuthor(commit.AuthorAndEmail);

            if (a == null)
            {
                checkinOptions.AuthorTfsUserId = null;
                return;
            }

            checkinOptions.AuthorTfsUserId = a.TfsUserId;
            writer.WriteLine("Commit was authored by git user {0} {1} ({2})", a.Name, a.Email, a.TfsUserId);
        }
示例#20
0
 public CommitSpecificCheckinOptionsFactory(TextWriter writer, Globals globals, AuthorsFile authors)
 {
     this.writer  = writer;
     this.globals = globals;
     this.authors = authors;
 }
示例#21
0
 public QuickFetch(Globals globals, RemoteOptions remoteOptions, AuthorsFile authors) : base(globals, remoteOptions, authors, null)
 {
 }
示例#22
0
 public InitBranch4Test(TextWriter stdout, Globals globals, Help helper, AuthorsFile authors)
     : base(stdout, globals, helper, authors)
 {
 }
        private void ProcessAuthor(CheckinOptions checkinOptions, TextWriter writer, GitCommit commit)
        {
            if (checkinOptions.AuthorsFilePath == null)
            {
                writer.WriteLine("Author file was not set.");
                return;
            }

            // get authors file FIXME
            AuthorsFile af = new AuthorsFile();
            TextReader tr = new StreamReader(checkinOptions.AuthorsFilePath);
            af.Parse(tr);

            Author a = af.FindAuthor(commit.AuthorAndEmail);
            if (a == null)
            {
                checkinOptions.AuthorTfsUserId = null;
                return;
            }

            checkinOptions.AuthorTfsUserId = a.TfsUserId;
            writer.WriteLine("Commit was authored by git user {0} {1} ({2})", a.Name, a.Email, a.TfsUserId);
        }
示例#24
0
        public CheckinOptions BuildCommitSpecificCheckinOptions(CheckinOptions sourceCheckinOptions,
                                                                string commitMessage, GitCommit commit, AuthorsFile authors)
        {
            var customCheckinOptions = BuildCommitSpecificCheckinOptions(sourceCheckinOptions, commitMessage);

            customCheckinOptions.ProcessAuthor(commit, authors);

            return(customCheckinOptions);
        }
示例#25
0
文件: Labels.cs 项目: runt18/git-tfs
 public Labels(TextWriter stdout, Globals globals, AuthorsFile authors)
 {
     this._stdout = stdout;
     this._globals = globals;
     this._authors = authors;
 }
示例#26
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"));
        }
示例#27
0
 public Labels(Globals globals, AuthorsFile authors)
 {
     _globals = globals;
     _authors = authors;
 }
示例#28
0
 public QuickFetch(Globals globals, TextWriter stdout, RemoteOptions remoteOptions, AuthorsFile authors)
     : base(globals, stdout, remoteOptions, authors, null)
 {
 }
 public CommitSpecificCheckinOptionsFactory(TextWriter writer, Globals globals, AuthorsFile authors)
 {
     this.writer = writer;
     this.globals = globals;
     this.authors = authors;
 }
        private void ProcessAuthor(CheckinOptions checkinOptions, TextWriter writer, GitCommit commit)
        {
            // get authors file FIXME
            AuthorsFile af = new AuthorsFile();
            if (!af.Parse(checkinOptions.AuthorsFilePath, globals.GitDir))
                return;

            Author a = af.FindAuthor(commit.AuthorAndEmail);
            if (a == null)
            {
                checkinOptions.AuthorTfsUserId = null;
                return;
            }

            checkinOptions.AuthorTfsUserId = a.TfsUserId;
            writer.WriteLine("Commit was authored by git user {0} {1} ({2})", a.Name, a.Email, a.TfsUserId);
        }
示例#31
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)))));
        }
示例#32
0
        public void AuthorsFileInternationalCharactersMultiLine()
        {
            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>(2, authFile.Authors.Count);
            Assert.True(authFile.Authors.ContainsKey(@"domain\Blåbærsyltetøy"));
            Author auth = authFile.Authors[@"domain\Blåbærsyltetøy"];
            Assert.Equal<string>("ÆØÅ User", auth.Name);
            Assert.Equal<string>("ÆØÅ@example.com", auth.Email);

            Assert.True(authFile.Authors.ContainsKey(@"differentDomain\Blåbærsyltetøy"));
            auth = authFile.Authors[@"differentDomain\Blåbærsyltetøy"];
            Assert.Equal<string>("ÆØÅ User", auth.Name);
            Assert.Equal<string>("ÆØÅ@example.com", auth.Email);
        }
示例#33
0
 public QuickFetch(Globals globals, ConfigProperties properties, TextWriter stdout, RemoteOptions remoteOptions, AuthorsFile authors)
     : base(globals, properties, stdout, remoteOptions, authors, null)
 {
     _properties = properties;
 }
示例#34
0
 public InitBranch(Globals globals, Help helper, AuthorsFile authors)
 {
     _globals = globals;
     _helper = helper;
 }
示例#35
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;
        }