You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement commit message line unwrapping for PR creation
- Add unwrapCommitMessageBody function to join wrapped lines
- Preserve blank lines, list items, quotes, and indented content
- Add comprehensive tests for various unwrapping scenarios
- Matches GitHub's behavior when converting commit messages to PR descriptions
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copy file name to clipboardExpand all lines: src/test/github/folderRepositoryManager.test.ts
+72Lines changed: 72 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -94,4 +94,76 @@ describe('titleAndBodyFrom', function () {
94
94
assert.strictEqual(result?.title,'title');
95
95
assert.strictEqual(result?.body,'');
96
96
});
97
+
98
+
it('unwraps wrapped lines in body',asyncfunction(){
99
+
constmessage=Promise.resolve('title\n\nThis is a long line that has been wrapped at 72 characters\nto fit the conventional commit message format.');
100
+
101
+
constresult=awaittitleAndBodyFrom(message);
102
+
assert.strictEqual(result?.title,'title');
103
+
assert.strictEqual(result?.body,'This is a long line that has been wrapped at 72 characters to fit the conventional commit message format.');
104
+
});
105
+
106
+
it('preserves blank lines as paragraph breaks',asyncfunction(){
107
+
constmessage=Promise.resolve('title\n\nFirst paragraph that is wrapped\nacross multiple lines.\n\nSecond paragraph that is also wrapped\nacross multiple lines.');
108
+
109
+
constresult=awaittitleAndBodyFrom(message);
110
+
assert.strictEqual(result?.title,'title');
111
+
assert.strictEqual(result?.body,'First paragraph that is wrapped across multiple lines.\n\nSecond paragraph that is also wrapped across multiple lines.');
112
+
});
113
+
114
+
it('preserves list items',asyncfunction(){
115
+
constmessage=Promise.resolve('title\n\n- First item\n- Second item\n- Third item');
116
+
117
+
constresult=awaittitleAndBodyFrom(message);
118
+
assert.strictEqual(result?.title,'title');
119
+
assert.strictEqual(result?.body,'- First item\n- Second item\n- Third item');
120
+
});
121
+
122
+
it('preserves numbered list items',asyncfunction(){
123
+
constmessage=Promise.resolve('title\n\n1. First item\n2. Second item\n3. Third item');
124
+
125
+
constresult=awaittitleAndBodyFrom(message);
126
+
assert.strictEqual(result?.title,'title');
127
+
assert.strictEqual(result?.body,'1. First item\n2. Second item\n3. Third item');
128
+
});
129
+
130
+
it('preserves indented lines',asyncfunction(){
131
+
constmessage=Promise.resolve('title\n\nNormal paragraph.\n\n Indented code block\n More code');
132
+
133
+
constresult=awaittitleAndBodyFrom(message);
134
+
assert.strictEqual(result?.title,'title');
135
+
assert.strictEqual(result?.body,'Normal paragraph.\n\n Indented code block\n More code');
136
+
});
137
+
138
+
it('unwraps but preserves asterisk list items',asyncfunction(){
139
+
constmessage=Promise.resolve('title\n\n* First item\n* Second item');
140
+
141
+
constresult=awaittitleAndBodyFrom(message);
142
+
assert.strictEqual(result?.title,'title');
143
+
assert.strictEqual(result?.body,'* First item\n* Second item');
144
+
});
145
+
146
+
it('handles mixed content with wrapped paragraphs and lists',asyncfunction(){
147
+
constmessage=Promise.resolve('title\n\nThis is a paragraph that has been wrapped\nat 72 characters.\n\n- Item 1\n- Item 2\n\nAnother wrapped paragraph\nthat continues here.');
148
+
149
+
constresult=awaittitleAndBodyFrom(message);
150
+
assert.strictEqual(result?.title,'title');
151
+
assert.strictEqual(result?.body,'This is a paragraph that has been wrapped at 72 characters.\n\n- Item 1\n- Item 2\n\nAnother wrapped paragraph that continues here.');
152
+
});
153
+
154
+
it('preserves lines with special characters at the start',asyncfunction(){
155
+
constmessage=Promise.resolve('title\n\n> Quote line 1\n> Quote line 2');
156
+
157
+
constresult=awaittitleAndBodyFrom(message);
158
+
assert.strictEqual(result?.title,'title');
159
+
assert.strictEqual(result?.body,'> Quote line 1\n> Quote line 2');
160
+
});
161
+
162
+
it('handles wrapped lines with punctuation',asyncfunction(){
163
+
constmessage=Promise.resolve('title\n\nThis is a sentence.\nThis is another sentence on a new line.');
164
+
165
+
constresult=awaittitleAndBodyFrom(message);
166
+
assert.strictEqual(result?.title,'title');
167
+
assert.strictEqual(result?.body,'This is a sentence. This is another sentence on a new line.');
0 commit comments