Skip to content

Commit

Permalink
Add some more logging to make it easier to find branches (#3006)
Browse files Browse the repository at this point in the history
Since all github events are passed to this endpoint, but we only care about branch events, add some logging so that we can find information about a specific branch in the log explorer easier.
  • Loading branch information
drewroengoogle authored Aug 24, 2023
1 parent c85b4f3 commit da0d2f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ class GithubBranchWebhookSubscription extends SubscriptionHandler {

final pb.GithubWebhookMessage webhook = pb.GithubWebhookMessage.fromJson(message.data!);
if (webhook.event != kWebhookCreateEvent) {
log.fine('Github event is not a "create" event, so this event will not be processed');
return Body.empty;
}

log.fine('Processing ${webhook.event}');
final CreateEvent createEvent = CreateEvent.fromJson(json.decode(webhook.payload) as Map<String, dynamic>);
log.fine('Handling create request for branch ${createEvent.ref}');
await branchService.handleCreateRequest(createEvent);

final RegExp candidateBranchRegex = RegExp(r'flutter-\d+\.\d+-candidate\.\d+');
if (candidateBranchRegex.hasMatch(createEvent.ref!)) {
log.fine('Branch ${createEvent.ref} is a candidate branch, creating new commit in the datastore');
await commitService.handleCreateGithubRequest(createEvent);
}

Expand Down
4 changes: 3 additions & 1 deletion app_dart/lib/src/service/commit_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ class CommitService {
final DatastoreService datastore = datastoreProvider(config.db);
final RepositorySlug slug = RepositorySlug.full(createEvent.repository!.fullName);
final String branch = createEvent.ref!;
log.info('Creating commit object for branch $branch in repository ${slug.fullName}');
final Commit commit = await _createCommitFromBranchEvent(datastore, slug, branch);

try {
log.info('Checking for existing commit in the datastore');
await datastore.lookupByValue<Commit>(commit.key);
} on KeyNotFoundException {
log.info('commit does not exist in datastore, inserting into datastore');
log.info('Commit does not exist in datastore, inserting into datastore');
await datastore.insert(<Commit>[commit]);
}
}
Expand Down

0 comments on commit da0d2f4

Please sign in to comment.