Title: [294161] trunk/Websites/bugs.webkit.org
- Revision
- 294161
- Author
- [email protected]
- Date
- 2022-05-13 10:05:55 -0700 (Fri, 13 May 2022)
Log Message
[PrettyPatch] Support commit messages
https://bugs.webkit.org/show_bug.cgi?id=240386
<rdar://problem/93248835>
Rubber-stamped by Aakash Jain.
* Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb:
(PrettyPatch.message_header): Match a commit message header.
(PrettyPatch.message_footer): Match a commit message footer.
(PrettyPatch.MESSAGE_HEADER_FORMATS): List of commit message headers.
(PrettyPatch.BUG_URL_RE): Regex to match bug urls in subject.
(PrettyPatch.MESSAGE_FOOTER_FORMATS): List of commit messagae footers.
(PrettyPatch.parse): Treat commit messages a new file named 'COMMIT_MESSAGE'.
Canonical link: https://commits.webkit.org/250530@main
Modified Paths
Diff
Modified: trunk/Websites/bugs.webkit.org/ChangeLog (294160 => 294161)
--- trunk/Websites/bugs.webkit.org/ChangeLog 2022-05-13 16:31:40 UTC (rev 294160)
+++ trunk/Websites/bugs.webkit.org/ChangeLog 2022-05-13 17:05:55 UTC (rev 294161)
@@ -1,3 +1,19 @@
+2022-05-13 Jonathan Bedard <[email protected]>
+
+ [PrettyPatch] Support commit messages
+ https://bugs.webkit.org/show_bug.cgi?id=240386
+ <rdar://problem/93248835>
+
+ Rubber-stamped by Aakash Jain.
+
+ * PrettyPatch/PrettyPatch.rb:
+ (PrettyPatch.message_header): Match a commit message header.
+ (PrettyPatch.message_footer): Match a commit message footer.
+ (PrettyPatch.MESSAGE_HEADER_FORMATS): List of commit message headers.
+ (PrettyPatch.BUG_URL_RE): Regex to match bug urls in subject.
+ (PrettyPatch.MESSAGE_FOOTER_FORMATS): List of commit messagae footers.
+ (PrettyPatch.parse): Treat commit messages a new file named 'COMMIT_MESSAGE'.
+
2022-05-09 Jonathan Bedard <[email protected]>
[bugs.webkit.org] Use GitHub as baseline when diffing
Modified: trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb (294160 => 294161)
--- trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb 2022-05-13 16:31:40 UTC (rev 294160)
+++ trunk/Websites/bugs.webkit.org/PrettyPatch/PrettyPatch.rb 2022-05-13 17:05:55 UTC (rev 294161)
@@ -47,6 +47,14 @@
RELAXED_DIFF_HEADER_FORMATS.any? { |format| line =~ format }
end
+ def self.message_header?(line)
+ MESSAGE_HEADER_FORMATS.any? { |format| line =~ format }
+ end
+
+ def self.message_footer?(line)
+ MESSAGE_FOOTER_FORMATS.any? { |format| line =~ format }
+ end
+
private
DIFF_HEADER_FORMATS = [
/^Index: (.*)\r?$/,
@@ -59,6 +67,16 @@
/^diff/
]
+ MESSAGE_HEADER_FORMATS = [
+ /^Subject: \[PATCH ?(\d+\/\d+)?\] (.+)/
+ ]
+
+ BUG_URL_RE = / (Need the bug URL \(OOPS!\).)|(\S+:\/\/\S+)/
+
+ MESSAGE_FOOTER_FORMATS = [
+ /^---/
+ ]
+
RENAME_FROM = /^rename from (.*)/
SVN_BINARY_FILE_MARKER_FORMAT = /^Cannot display: file marked as a binary type.$/
@@ -777,7 +795,9 @@
end
def self.parse(string)
+ commitMessageLength = 0
haveSeenDiffHeader = false
+ subject = ''
linesForDiffs = []
line_array = string.lines.to_a
line_array.each_with_index do |line, index|
@@ -787,8 +807,38 @@
elsif (!haveSeenDiffHeader && line =~ /^--- / && line_array[index + 1] =~ /^\+\+\+ /)
linesForDiffs << []
haveSeenDiffHeader = false
+ elsif (PrettyPatch.message_header?(line))
+ haveSeenDiffHeader = false
+ parsingSubject = true
+ commitMessageLength = 1
+ linesForDiffs << []
+ linesForDiffs.last << '+++ COMMIT_MESSAGE'
+ if line[MESSAGE_HEADER_FORMATS[0], 1]
+ linesForDiffs.last[-1] += ' (' + line[MESSAGE_HEADER_FORMATS[0], 1] + ')'
+ end
+ linesForDiffs.last << '@@ -0,0 +1,1 @@'
+ subject = line[MESSAGE_HEADER_FORMATS[0], 2]
+ elsif (!subject.empty? && line.strip.empty?)
+ subject.split(BUG_URL_RE).each { |mtch|
+ if !mtch.strip.empty?
+ commitMessageLength += 1
+ linesForDiffs.last << '+' + mtch
+ end
+ }
+ subject = ''
+ elsif (!subject.empty?)
+ subject += line
+ elsif (commitMessageLength != 0 && PrettyPatch.message_footer?(line))
+ linesForDiffs.last[1] = '@@ -0,0 +1,' + commitMessageLength.to_s + ' @@'
+ commitMessageLength = 0
end
- linesForDiffs.last << line unless linesForDiffs.last.nil?
+
+ if (subject.empty? && commitMessageLength != 0)
+ commitMessageLength += 1
+ linesForDiffs.last << '+' + line unless linesForDiffs.last.nil?
+ elsif (subject.empty? && haveSeenDiffHeader)
+ linesForDiffs.last << line unless linesForDiffs.last.nil?
+ end
end
linesForDiffs.collect { |lines| FileDiff.new(lines) }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes