Пример #1
0
def format_reflog_line(old_sha, new_sha, committer, timestamp, timezone,
                       message):
    """Generate a single reflog line.

    :param old_sha: Old Commit SHA
    :param new_sha: New Commit SHA
    :param committer: Committer name and e-mail
    :param timestamp: Timestamp
    :param timezone: Timezone
    :param message: Message
    """
    if old_sha is None:
        old_sha = ZERO_SHA
    return (old_sha + b' ' + new_sha + b' ' + committer + b' ' +
            str(int(timestamp)).encode('ascii') + b' ' +
            format_timezone(timezone) + b'\t' + message)
Пример #2
0
def print_commit(commit, decode, outstream=sys.stdout):
    """Write a human-readable commit log entry.

    :param commit: A `Commit` object
    :param outstream: A stream file to write to
    """
    outstream.write("-" * 50 + "\n")
    outstream.write("commit: " + commit.id.decode('ascii') + "\n")
    if len(commit.parents) > 1:
        outstream.write(
            "merge: " +
            "...".join([c.decode('ascii') for c in commit.parents[1:]]) + "\n")
    outstream.write("Author: " + decode(commit.author) + "\n")
    if commit.author != commit.committer:
        outstream.write("Committer: " + decode(commit.committer) + "\n")

    time_tuple = time.gmtime(commit.author_time + commit.author_timezone)
    time_str = time.strftime("%a %b %d %Y %H:%M:%S", time_tuple)
    timezone_str = format_timezone(commit.author_timezone).decode('ascii')
    outstream.write("Date:   " + time_str + " " + timezone_str + "\n")
    outstream.write("\n")
    outstream.write(decode(commit.message) + "\n")
    outstream.write("\n")
 def test_format_timezone_double_negative(self):
     self.assertEqual(b'--700', format_timezone(int(((7 * 60)) * 60), True))
 def test_format_timezone_pdt_half(self):
     self.assertEqual(b'-0440', format_timezone(int(((-4 * 60) - 40) * 60)))
 def test_format_timezone_pdt(self):
     self.assertEqual(b'-0400', format_timezone(-4 * 60 * 60))
 def test_format_timezone_cet(self):
     self.assertEqual(b'+0100', format_timezone(60 * 60))
 def test_generate_timezone_utc_negative(self):
     self.assertEqual(b'-0000', format_timezone(0, True))
 def test_generate_timezone_utc(self):
     self.assertEqual(b'+0000', format_timezone(0))