Skip to content

Commit fbe0274

Browse files
BoyangTian-RobinhoodDaniel Kozlowski
authored andcommitted
Fix no branch for devhooks (#14)
1 parent 7820454 commit fbe0274

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/workflow/ArcanistDiffWorkflow.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,17 +623,30 @@ public function run() {
623623
}
624624

625625
if ($this->getDevxMetricsEnabled()) {
626+
try {
627+
$branch_create_ts = $repository_api->getBranchCreationTS() * 1000;
628+
}
629+
catch (Exception $e) {
630+
# When developer do `arc diff` which out a branch it will has this exception
631+
# https://hood.slack.com/archives/C016GGP0QDD/p1660233270559149
632+
# Therefore we use current time as the branch create time
633+
$branch_create_ts = time() * 1000;
634+
}
626635
try {
627636
$ch = curl_init("https://devhooks.build.rhinternal.net/api/events/");
628637

629638
$repository_api = $this->getRepositoryAPI();
630-
$branch_create_ts = $repository_api->getBranchCreationTS() * 1000;
631639
$base_commit_sha = $repository_api->getBaseCommit();
632640
$base_commit_ts = $repository_api->getCommitTS($base_commit_sha) * 1000;
633641
$head_commit_sha = $repository_api->getHeadCommit();
634642
$head_commit_ts = $repository_api->getCommitTS($head_commit_sha) * 1000;
635643
$author = $this->getUserName();
636644
$branch_name = $repository_api->getBranchName();
645+
if ($branch_name == null) {
646+
# When developer do `arc diff` which out a branch it will has this exception
647+
# https://hood.slack.com/archives/C016GGP0QDD/p1660233270559149
648+
$branch_name = "devx-kpi-nobranch";
649+
}
637650
$hostname = gethostname();
638651
$payload = json_encode(array(
639652
"event_type" => "dev_branch_info",

0 commit comments

Comments
 (0)