Skip to content

Commit 5e15238

Browse files
committed
Revert "Merge pull request #2199 from Urgau/gha-logs-better-uncopy"
This reverts commit b6ec119, reversing changes made to a983074.
1 parent b6ec119 commit 5e15238

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/gha_logs.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,30 +211,19 @@ pub async fn gha_logs(
211211
<title>{job_name} - {owner}/{repo}@{short_sha}</title>
212212
{icon_status}
213213
<style>
214-
:root {{
215-
--timestamp-length: 28ch;
216-
}}
217214
body {{
218215
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
219216
background: #0C0C0C;
220217
color: #CCC;
221218
white-space: pre;
222-
padding-left: calc(var(--timestamp-length) + 1ch);
223-
margin: 0;
224219
}}
225220
.timestamp {{
226221
color: #848484;
227222
text-decoration: none;
228-
position: absolute;
229-
left: 0;
230-
width: var(--timestamp-length);
231223
}}
232224
.timestamp:hover {{
233225
text-decoration: underline;
234226
}}
235-
.timestamp::before {{
236-
content: attr(data-timestamp);
237-
}}
238227
.error-marker {{
239228
scroll-margin-bottom: 15vh;
240229
color: #e5534b;
@@ -286,9 +275,9 @@ body {{
286275
}}
287276
288277
// 3. Add a self-referencial anchor to all timestamps at the start of the lines
289-
const dateRegex = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z) /gm;
290-
html = html.replace(dateRegex, (match, ts) =>
291-
`<a id="${{ts}}" href="#${{ts}}" class="timestamp" data-timestamp="${{ts}}"></a>`
278+
const dateRegex = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z)/gm;
279+
html = html.replace(dateRegex, (ts) =>
280+
`<a id="${{ts}}" href="#${{ts}}" class="timestamp">${{ts}}</a>`
292281
);
293282
294283
// 4. Add a anchor around every "##[error]" string
@@ -348,9 +337,11 @@ body {{
348337
}});
349338
}}
350339
351-
// 8. Add a copy handler that force plain/text copy
340+
// 8. Add a copy handler that force plain/text copy and removes the timestamps
341+
// from the copied selection.
342+
const dateRegexWithSpace = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z )/gm;
352343
document.addEventListener("copy", function(e) {{
353-
var text = window.getSelection().toString();
344+
var text = window.getSelection().toString().replace(dateRegexWithSpace, '');
354345
e.clipboardData.setData('text/plain', text);
355346
e.preventDefault();
356347
}});

0 commit comments

Comments
 (0)