Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2896124
ArcanistCommentRemover.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
678 B
Referenced Files
None
Subscribers
None
ArcanistCommentRemover.php
View Options
<?php
final
class
ArcanistCommentRemover
extends
Phobject
{
/**
* Remove comment lines from a commit message. Strips trailing lines only,
* and requires "#" to appear at the beginning of a line for it to be
* considered a comment.
*/
public
static
function
removeComments
(
$body
)
{
$lines
=
explode
(
"\n"
,
$body
)
;
$lines
=
array_reverse
(
$lines
)
;
foreach
(
$lines
as
$key
=>
$line
)
{
if
(
!
strlen
(
$line
)
)
{
unset
(
$lines
[
$key
]
)
;
continue
;
}
if
(
$line
[
0
]
==
'#'
)
{
unset
(
$lines
[
$key
]
)
;
continue
;
}
break
;
}
$lines
=
array_reverse
(
$lines
)
;
return
implode
(
"\n"
,
$lines
)
.
"\n"
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Jan 19 2025, 22:35 (6 w, 3 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1113047
Default Alt Text
ArcanistCommentRemover.php (678 B)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment