public Parse ( |
||
authorsFileStream | ||
return | bool |
public void TestBadRecord() { string author = @"Domain\Test.User = Test User"; AuthorsFile authFile = new AuthorsFile(); authFile.Parse(new StreamReader(new MemoryStream(Encoding.ASCII.GetBytes(author)))); }
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); }
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))))); }
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); }
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); }
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 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); }
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); }
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 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))))); }
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; }
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")); }
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); }