示例#1
0
        //
        //
        //
        //
        //
        //
        /// <summary>Compute a Change-Id.</summary>
        /// <remarks>Compute a Change-Id.</remarks>
        /// <param name="treeId">The id of the tree that would be committed</param>
        /// <param name="firstParentId">parent id of previous commit or null</param>
        /// <param name="author">
        /// the
        /// <see cref="NGit.PersonIdent">NGit.PersonIdent</see>
        /// for the presumed author and time
        /// </param>
        /// <param name="committer">
        /// the
        /// <see cref="NGit.PersonIdent">NGit.PersonIdent</see>
        /// for the presumed committer and time
        /// </param>
        /// <param name="message">The commit message</param>
        /// <returns>
        /// the change id SHA1 string (without the 'I') or null if the
        /// message is not complete enough
        /// </returns>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        public static ObjectId ComputeChangeId(ObjectId treeId, ObjectId firstParentId, PersonIdent
                                               author, PersonIdent committer, string message)
        {
            string cleanMessage = Clean(message);

            if (cleanMessage.Length == 0)
            {
                return(null);
            }
            StringBuilder b = new StringBuilder();

            b.Append("tree ");
            b.Append(ObjectId.ToString(treeId));
            b.Append("\n");
            if (firstParentId != null)
            {
                b.Append("parent ");
                b.Append(ObjectId.ToString(firstParentId));
                b.Append("\n");
            }
            b.Append("author ");
            b.Append(author.ToExternalString());
            b.Append("\n");
            b.Append("committer ");
            b.Append(committer.ToExternalString());
            b.Append("\n\n");
            b.Append(cleanMessage);
            return(new ObjectInserter.Formatter().IdFor(Constants.OBJ_COMMIT, Sharpen.Runtime.GetBytesForString
                                                            (b.ToString(), Constants.CHARACTER_ENCODING)));
        }
示例#2
0
 public void test001_NewIdent()
 {
     PersonIdent p = new PersonIdent("A U Thor", "*****@*****.**", 1142878501L, 0);
     Assert.AreEqual("A U Thor", p.Name);
     Assert.AreEqual("*****@*****.**", p.EmailAddress);
     Assert.AreEqual(1142878501L, p.When.ToGitInternalTime());
     Assert.AreEqual("A U Thor <*****@*****.**> 1142878501 +0000", p.ToExternalString());
 }
示例#3
0
 public void test002_ParseIdent()
 {
     string i = "A U Thor <*****@*****.**> 1142878501 -0500";
     var p = new PersonIdent(i);
     Assert.AreEqual(i, p.ToExternalString());
     Assert.AreEqual("A U Thor", p.Name);
     Assert.AreEqual("*****@*****.**", p.EmailAddress);
     Assert.AreEqual(1142878501000L, p.When);
 }
示例#4
0
 public void test001_NewIdent()
 {
     var p = new PersonIdent("A U Thor", "*****@*****.**", 1142878501L.UnixTimeToDateTime(),
                             TimeZoneInfo.FindSystemTimeZoneById("US/Eastern"));
     Assert.AreEqual("A U Thor", p.Name);
     Assert.AreEqual("*****@*****.**", p.EmailAddress);
     Assert.AreEqual(1142878501000L, p.When);
     Assert.AreEqual("A U Thor <*****@*****.**> 1142878501 -0500", p
                                                                           .ToExternalString());
 }
示例#5
0
        private static void putPersonIdent(IDictionary <String, String> env,
                                           string type, PersonIdent who)
        {
            string ident = who.ToExternalString();
            string date  = ident.Substring(ident.IndexOf("> ") + 2);

            env.put("GIT_" + type + "_NAME", who.Name);
            env.put("GIT_" + type + "_EMAIL", who.EmailAddress);
            env.put("GIT_" + type + "_DATE", date);
        }
示例#6
0
        public void test003_ParseIdent()
        {
            string i = "A U Thor <*****@*****.**> 1142878501 +0230";
            var    p = new PersonIdent(i);

            Assert.AreEqual(i, p.ToExternalString());
            Assert.AreEqual("A U Thor", p.Name);
            Assert.AreEqual("*****@*****.**", p.EmailAddress);
            Assert.AreEqual(1142878501000L, p.When);
        }
示例#7
0
        public void test001_NewIdent()
        {
            PersonIdent p;

            p = new PersonIdent("A U Thor", "*****@*****.**", 1142878501L.UnixTimeToDateTime(),
                                (int)new TimeSpan(-5, 0, 0).TotalMinutes);

            Assert.AreEqual("A U Thor", p.Name);
            Assert.AreEqual("*****@*****.**", p.EmailAddress);
            Assert.AreEqual(1142878501000L, p.When);
            Assert.AreEqual("A U Thor <*****@*****.**> 1142878501 -0500", p.ToExternalString());
        }
示例#8
0
        internal virtual string ToAuthorScript(PersonIdent author)
        {
            StringBuilder sb = new StringBuilder(100);

            sb.Append(GIT_AUTHOR_NAME);
            sb.Append("='");
            sb.Append(author.GetName());
            sb.Append("'\n");
            sb.Append(GIT_AUTHOR_EMAIL);
            sb.Append("='");
            sb.Append(author.GetEmailAddress());
            sb.Append("'\n");
            // the command line uses the "external String"
            // representation for date and timezone
            sb.Append(GIT_AUTHOR_DATE);
            sb.Append("='");
            string externalString = author.ToExternalString();

            sb.Append(Sharpen.Runtime.Substring(externalString, externalString.LastIndexOf('>'
                                                                                           ) + 2));
            sb.Append("'\n");
            return(sb.ToString());
        }
示例#9
0
 public void test003_ParseIdent()
 {
     String i = "A U Thor <*****@*****.**> 1142878501 +0230";
     PersonIdent p = new PersonIdent(i);
     Assert.AreEqual(i, p.ToExternalString());
     Assert.AreEqual("A U Thor", p.Name);
     Assert.AreEqual("*****@*****.**", p.EmailAddress);
     Assert.AreEqual(1142878501L, p.When.ToGitInternalTime());
 }