Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F20136031
ports/cherry-pick
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
mat
Apr 15 2021, 3:03 PM
2021-04-15 15:03:03 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
ports/cherry-pick
View Options
#!/usr/bin/perl
# vim:sts=4 sw=4
use
strict
;
use
warnings
;
use
5.024
;
sub
short_ref
{
my
(
$ref
)
=
@_
;
$ref
=~
s{refs/heads/}{}oms
;
return
$ref
;
}
my
$push_option_count
=
$ENV
{
GIT_PUSH_OPTION_COUNT
};
for
(
my
$i
=
0
;
$i
<
$push_option_count
;
++
$i
)
{
exit
0
if
$ENV
{
"GIT_PUSH_OPTION_${i}"
}
eq
"direct-quarterly-commit"
;
}
my
@quarterlies
;
for
(
qx{git show-ref --heads}
)
{
chomp
;
my
(
$hash
,
$ref
)
=
split
/ /
;
next
if
$ref
!~
m{refs/heads/\d\d\d\dQ\d\z}oms
;
push
@quarterlies
,
$ref
;
}
@quarterlies
=
sort
@quarterlies
;
my
$latest
=
$quarterlies
[
-
1
];
for
(
<STDIN>
)
{
chomp
;
my
(
$old
,
$new
,
$ref
)
=
split
/ /
;
next
if
$ref
!~
m{^refs/heads/20\d\dQ\d\z}oms
;
REV:
for
my
$rev
(
qx{git log --format="%H" $new --not --all}
)
{
chomp
$rev
;
for
my
$line
(
qx{git show -s --format=%B $rev}
)
{
next
REV
if
$line
=~
/cherry picked from commit [0-9a-fA-F]{40}/
}
die
"\n================================================================\n"
.
"$ENV{GL_USER}, you are pushing a commit to ${\(short_ref($ref))} which does\n"
.
"not seems to be a cherry-pick.\n"
.
"\n"
.
"If you did a cherry-pick, you probably forgot to add `-x`,\n"
.
"make sure you do run `git cherry-pick -x <hash>`.\n"
.
"\n"
.
"If you did a direct commit, make sure it was approved first, and then run:\n"
.
"\tgit push --push-option=direct-quarterly-commit\n"
.
"================================================================\n"
}
}
exit
0
;
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3597547
Default Alt Text
ports/cherry-pick (1 KB)
Attached To
Mode
P493 ports/cherry-pick
Attached
Detach File
Event Timeline
Log In to Comment