|
@@ -0,0 +1,57 @@
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+"""Classes for dealing with git am-style patches.
|
|
|
+
|
|
|
+These patches are basically unified diffs with some extra metadata tacked
|
|
|
+on.
|
|
|
+"""
|
|
|
+
|
|
|
+import time
|
|
|
+
|
|
|
+def write_commit_patch(f, commit, progress, version=None):
|
|
|
+ """Write a individual file patch.
|
|
|
+
|
|
|
+ :param commit: Commit object
|
|
|
+ :param progress: Tuple with current patch number and total.
|
|
|
+ :return: tuple with filename and contents
|
|
|
+ """
|
|
|
+ (num, total) = progress
|
|
|
+ f.write("From %s %s\n" % (commit.id, time.ctime(commit.commit_time)))
|
|
|
+ f.write("From: %s\n" % commit.author)
|
|
|
+ f.write("Date: %s\n" % time.strftime("%a, %d %b %Y %H:%M:%S %Z"))
|
|
|
+ f.write("Subject: [PATCH %d/%d] %s\n" % (num, total, commit.message))
|
|
|
+ f.write("\n")
|
|
|
+ f.write("---\n")
|
|
|
+ f.write("TODO: Print diffstat\n")
|
|
|
+ f.write("\n")
|
|
|
+ f.write("-- \n")
|
|
|
+ if version is None:
|
|
|
+ from dulwich import __version__ as dulwich_version
|
|
|
+ f.write("Dulwich %d.%d.%d\n" % dulwich_version)
|
|
|
+ else:
|
|
|
+ f.write("%s\n" % version)
|
|
|
+
|
|
|
+
|
|
|
+def get_summary(commit):
|
|
|
+ """Determine the summary line for use in a filename.
|
|
|
+
|
|
|
+ :param commit: Commit
|
|
|
+ :return: Summary string
|
|
|
+ """
|
|
|
+ return commit.message.splitlines()[0].replace(" ", "-")
|