Example #1
0
 /// <summary>Copy a PersonIdent, but alter the clone's time stamp</summary>
 /// <param name="pi">
 /// original
 /// <see cref="PersonIdent">PersonIdent</see>
 /// </param>
 /// <param name="aWhen">local time stamp</param>
 /// <param name="aTZ">time zone</param>
 public PersonIdent(NGit.PersonIdent pi, long aWhen, int aTZ)
 {
     name         = pi.GetName();
     emailAddress = pi.GetEmailAddress();
     when         = aWhen;
     tzOffset     = aTZ;
 }
Example #2
0
 /// <summary>
 /// Copy a
 /// <see cref="PersonIdent">PersonIdent</see>
 /// , but alter the clone's time stamp
 /// </summary>
 /// <param name="pi">
 /// original
 /// <see cref="PersonIdent">PersonIdent</see>
 /// </param>
 /// <param name="aWhen">local time</param>
 public PersonIdent(NGit.PersonIdent pi, DateTime aWhen)
 {
     name         = pi.GetName();
     emailAddress = pi.GetEmailAddress();
     when         = aWhen.GetTime();
     tzOffset     = pi.tzOffset;
 }
		public virtual void Test002_NewIdent()
		{
			PersonIdent p = new PersonIdent("A U Thor", "*****@*****.**", Sharpen.Extensions.CreateDate
				(1142878501000L), Sharpen.Extensions.GetTimeZone("GMT+0230"));
			NUnit.Framework.Assert.AreEqual("A U Thor", p.GetName());
			NUnit.Framework.Assert.AreEqual("*****@*****.**", p.GetEmailAddress());
			NUnit.Framework.Assert.AreEqual(1142878501000L, p.GetWhen().GetTime());
			NUnit.Framework.Assert.AreEqual("A U Thor <*****@*****.**> 1142878501 +0230", 
				p.ToExternalString());
		}
Example #4
0
 public override bool Equals(object o)
 {
     if (o is NGit.PersonIdent)
     {
         NGit.PersonIdent p = (NGit.PersonIdent)o;
         return(GetName().Equals(p.GetName()) && GetEmailAddress().Equals(p.GetEmailAddress
                                                                              ()) && when / 1000L == p.when / 1000L);
     }
     return(false);
 }
        public virtual void Test002_NewIdent()
        {
            PersonIdent p = new PersonIdent("A U Thor", "*****@*****.**", Sharpen.Extensions.CreateDate
                                                (1142878501000L), Sharpen.Extensions.GetTimeZone("GMT+0230"));

            NUnit.Framework.Assert.AreEqual("A U Thor", p.GetName());
            NUnit.Framework.Assert.AreEqual("*****@*****.**", p.GetEmailAddress());
            NUnit.Framework.Assert.AreEqual(1142878501000L, p.GetWhen().GetTime());
            NUnit.Framework.Assert.AreEqual("A U Thor <*****@*****.**> 1142878501 +0230",
                                            p.ToExternalString());
        }
        public virtual void Test001_NewIdent()
        {
            var timeZoneId = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                                ? "Eastern Standard Time"
                                : "EST";
            PersonIdent p = new PersonIdent("A U Thor", "*****@*****.**", Sharpen.Extensions.CreateDate
                                                (1142878501000L), Sharpen.Extensions.GetTimeZone(timeZoneId));

            NUnit.Framework.Assert.AreEqual("A U Thor", p.GetName());
            NUnit.Framework.Assert.AreEqual("*****@*****.**", p.GetEmailAddress());
            NUnit.Framework.Assert.AreEqual(1142878501000L, p.GetWhen().GetTime());
            NUnit.Framework.Assert.AreEqual("A U Thor <*****@*****.**> 1142878501 -0500",
                                            p.ToExternalString());
        }
Example #7
0
 public virtual void TestAuthorScriptConverter()
 {
     // -1 h timezone offset
     PersonIdent ident = new PersonIdent("Author name", "*****@*****.**", 123456789123L
         , -60);
     string convertedAuthor = git.Rebase().ToAuthorScript(ident);
     string[] lines = convertedAuthor.Split("\n");
     NUnit.Framework.Assert.AreEqual("GIT_AUTHOR_NAME='Author name'", lines[0]);
     NUnit.Framework.Assert.AreEqual("GIT_AUTHOR_EMAIL='*****@*****.**'", lines[1]);
     NUnit.Framework.Assert.AreEqual("GIT_AUTHOR_DATE='123456789 -0100'", lines[2]);
     PersonIdent parsedIdent = git.Rebase().ParseAuthor(Sharpen.Runtime.GetBytesForString
         (convertedAuthor, "UTF-8"));
     NUnit.Framework.Assert.AreEqual(ident.GetName(), parsedIdent.GetName());
     NUnit.Framework.Assert.AreEqual(ident.GetEmailAddress(), parsedIdent.GetEmailAddress
         ());
     // this is rounded to the last second
     NUnit.Framework.Assert.AreEqual(123456789000L, parsedIdent.GetWhen().GetTime());
     NUnit.Framework.Assert.AreEqual(ident.GetTimeZoneOffset(), parsedIdent.GetTimeZoneOffset
         ());
     // + 9.5h timezone offset
     ident = new PersonIdent("Author name", "*****@*****.**", 123456789123L, +570);
     convertedAuthor = git.Rebase().ToAuthorScript(ident);
     lines = convertedAuthor.Split("\n");
     NUnit.Framework.Assert.AreEqual("GIT_AUTHOR_NAME='Author name'", lines[0]);
     NUnit.Framework.Assert.AreEqual("GIT_AUTHOR_EMAIL='*****@*****.**'", lines[1]);
     NUnit.Framework.Assert.AreEqual("GIT_AUTHOR_DATE='123456789 +0930'", lines[2]);
     parsedIdent = git.Rebase().ParseAuthor(Sharpen.Runtime.GetBytesForString(convertedAuthor
         , "UTF-8"));
     NUnit.Framework.Assert.AreEqual(ident.GetName(), parsedIdent.GetName());
     NUnit.Framework.Assert.AreEqual(ident.GetEmailAddress(), parsedIdent.GetEmailAddress
         ());
     NUnit.Framework.Assert.AreEqual(123456789000L, parsedIdent.GetWhen().GetTime());
     NUnit.Framework.Assert.AreEqual(ident.GetTimeZoneOffset(), parsedIdent.GetTimeZoneOffset
         ());
 }
		private string ToString(PersonIdent author)
		{
			StringBuilder a = new StringBuilder();
			a.Append("Author: ");
			a.Append(author.GetName());
			a.Append(" <");
			a.Append(author.GetEmailAddress());
			a.Append(">\n");
			a.Append("Date:   ");
			a.Append(dateFormatter.FormatDate(author));
			a.Append("\n");
			return a.ToString();
		}
Example #9
0
 private static Person ToPerson(PersonIdent ident)
 {
     return new Person(ident.GetName(), ident.GetEmailAddress());
 }
Example #10
0
 /// <summary>
 /// Copy a
 /// <see cref="PersonIdent">PersonIdent</see>
 /// .
 /// </summary>
 /// <param name="pi">
 /// Original
 /// <see cref="PersonIdent">PersonIdent</see>
 /// </param>
 public PersonIdent(NGit.PersonIdent pi) : this(pi.GetName(), pi.GetEmailAddress()
                                                )
 {
 }
Example #11
0
 /// <summary>Copy a PersonIdent, but alter the clone's time stamp</summary>
 /// <param name="pi">
 /// original
 /// <see cref="PersonIdent">PersonIdent</see>
 /// </param>
 /// <param name="when">local time</param>
 /// <param name="tz">time zone</param>
 public PersonIdent(NGit.PersonIdent pi, DateTime when, TimeZoneInfo tz) : this(pi
                                                                                .GetName(), pi.GetEmailAddress(), when, tz)
 {
 }
Example #12
0
 /// <summary>Copy a PersonIdent, but alter the clone's time stamp</summary>
 /// <param name="pi">
 /// original
 /// <see cref="PersonIdent">PersonIdent</see>
 /// </param>
 /// <param name="aWhen">local time stamp</param>
 /// <param name="aTZ">time zone</param>
 public PersonIdent(NGit.PersonIdent pi, long aWhen, int aTZ) : this(pi.GetName(),
                                                                     pi.GetEmailAddress(), aWhen, aTZ)
 {
 }
Example #13
0
 /// <summary>
 /// Copy a
 /// <see cref="PersonIdent">PersonIdent</see>
 /// , but alter the clone's time stamp
 /// </summary>
 /// <param name="pi">
 /// original
 /// <see cref="PersonIdent">PersonIdent</see>
 /// </param>
 /// <param name="aWhen">local time</param>
 public PersonIdent(NGit.PersonIdent pi, DateTime aWhen) : this(pi.GetName(), pi.GetEmailAddress
                                                                    (), aWhen.GetTime(), pi.tzOffset)
 {
 }