From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id B1E363858D37 for ; Fri, 22 Apr 2022 18:11:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B1E363858D37 Received: by mail-pl1-x634.google.com with SMTP id h12so8866613plf.12 for ; Fri, 22 Apr 2022 11:11:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yIcxCRzKMG+NKhwIzvU1rsRGIi7L8f69xFGcD+k7yIM=; b=ehgPp0b9rrfob9LIhg4ZRyJL9Yj2KCFG7Q/AaZnDTZFPhM32s4wXeSMgIR+jneOziq z2GhTz4LncEr0Y6LJWFPZG7b1rlvtgPJkMbI4hU+6SKo1vuT7Zj+nxJ/NGZEDzluvyGS mAykPRLAG/N+ZcvuVRUN4vfeitzytBwXaYN8RrIVvSoKATdpo5fOuqrZB1XUN1/mQwyf wAcrds3D07DFc3SskRyUXftuKps/MDxaY5dua9oKRUqfcIna5yGmQ2ntX4rZhfMtGorS i4ZB8BUZTjzpFLpzUavDJRKkLPjNVz/jT7I2LgB2Kjx2luXzd0uecWFw4+oqYokVor5o 6Xag== X-Gm-Message-State: AOAM531bzgSqJjH9YpsBnpd+qyewyvumwMk/wF2/TeASz+raPseA3aaB E51B2h8R4p5rFEAFt4ppv33x4tMMh2p4 X-Google-Smtp-Source: ABdhPJxnifJG2mMHvxim4vr6P8BMVdTTSN6n3GrWx+wod5ZQ1QXw7N5IQa8T989SP3cyE/EaDTXsJA== X-Received: by 2002:a17:902:6b47:b0:156:ae54:deaf with SMTP id g7-20020a1709026b4700b00156ae54deafmr5757844plt.129.1650651069765; Fri, 22 Apr 2022 11:11:09 -0700 (PDT) Received: from takamaka.home ([184.69.131.86]) by smtp.gmail.com with ESMTPSA id gm11-20020a17090b100b00b001cde015e02fsm6622440pjb.31.2022.04.22.11.11.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:11:08 -0700 (PDT) Received: by takamaka.home (Postfix, from userid 1000) id 9BBB7A4D6A; Fri, 22 Apr 2022 11:11:07 -0700 (PDT) Date: Fri, 22 Apr 2022 11:11:07 -0700 From: Joel Brobecker To: Simon Marchi Cc: "gdb@sourceware.org" , Joel Brobecker Subject: Re: Format of patterns recognized in commit messages for auto-posting in bugs Message-ID: References: <67dd0291-2672-9bd4-3b11-877207d11f7f@polymtl.ca> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="jjBY8MBGA/Y9+Y1H" Content-Disposition: inline In-Reply-To: <67dd0291-2672-9bd4-3b11-877207d11f7f@polymtl.ca> X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2022 18:11:14 -0000 --jjBY8MBGA/Y9+Y1H Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > What are the formats recognized by the git hooks to detect that a commit > refers to a Bugzilla bug, and post a message on that bug? We used to > write "PR gdb/1234" and it was recognized. Now, we use "Bug:" trailers, > like in this commit: > > https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=152a17495663ae9099d5efdc38322c9ad348014e > > ... but it doesn't seem recognized. Would it be possible to recognize > Bugzilla URLs? This is actually not handled by the git-hooks themselves. The hooks are simply configured to pass the information to a script which already exists prior to the hooks themselves. # Send a copy to bugzilla if a commit has a PR number in it. file-commit-cmd = "/sourceware/infra/bin/email-to-bugzilla -G 'gdb binutils'" I'm attaching the script to this email. Not sure who maintains that script, though. It doesn't look hard to enhance it further. -- Joel --jjBY8MBGA/Y9+Y1H Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=email-to-bugzilla #!/usr/bin/perl # -*-Perl-*- # # Perl filter to handle the log messages from the checkin of files in # a directory. This script will group the lists of files by log # message, and mail a single consolidated log message at the end of # the commit. # # This file assumes a pre-commit checking program that leaves the # names of the first and last commit directories in a temporary file. # # Contributed by David Hampton # # hacked greatly by Greg A. Woods # # Then chopped down just to send bugzilla email, for git. use strict; use POSIX; use DBI; use Mail::Header; use Mail::Internet; my $bugzillaproduct; # # Subroutines # sub see_if_bugzilla_bug_exists { my ($dbh, $product, $id) = @_; # Split $PRODUCT and SQL-ify. my $sql_product = ''; for my $i (split (/\s+/, $product)) { if ($sql_product ne '') { $sql_product .= ', '; } $sql_product .= "'" . $i . "'"; } my $sth2 = $dbh->prepare ("SELECT COUNT(*) from bugs where bug_id = $id and product_id = any (select products.id from products where name in ($sql_product))") or return 0; $sth2->execute() or return 0; my $count = $sth2->fetchrow_array (); return $count > 0; } sub mail_bug_notification { my $name = shift; my $subject = shift; my $head = Mail::Header->new; $head->add('From', 'cvs-commit@gcc.gnu.org'); $head->add('Subject', $subject); $head->add('To', $name); my $mail = Mail::Internet->new(Header => $head, Body => \@_); die "email send failed\n" if !$mail->send; } # # Main Body # # Initialize basic variables # my $debug = 0; # Parse command line arguments. while (my $arg = shift @ARGV) { if ($arg eq '-d') { $debug = 1; print STDERR "Debug turned on...\n"; } elsif ($arg eq '-G') { die "Too many '-G' args\n" if $bugzillaproduct; $bugzillaproduct = shift @ARGV; } } # Used with sprintf to form name of Gnats notification mailing list. # %s argument comse from -G option. my $MAIL_FORMAT = '%s-bugzilla@localhost'; # Collect the body of the commit message. binmode STDIN, ":utf8"; my @text = (); while () { push (@text, $_); } my $log_txt = join ('', @text); my %done_ids = {}; # fche/jakub 2020-04-01 ... this following matches "Apr" and spams PR1 #while ($log_txt =~ m/[^Aa]?(?:bug|PR|BZ)\s+\#?\s*(?:[a-z+-]+\/)?(?:\/)?(\d+)(.*)$/si) { while ($log_txt =~ m/\s(?:bug|PR|BZ)\s+\#?\s*(?:[a-z0-9+-]+\/)?(?:\/)?(\d+)(.*)$/si) { my $bug_id = $1; $log_txt = $2; if (!defined $done_ids{$bug_id}) { $done_ids{$bug_id} = 1; # Send mail to Bugzilla, if required. if ($bugzillaproduct ne '') { my $dbh = undef; if ($bugzillaproduct eq 'gcc') { $dbh = DBI->connect ("dbi:mysql:bugs", "swbugz", "everythingroses"); } else {# elsif ($bugzillaproduct eq 'glibc') $dbh = DBI->connect ("dbi:mysql:sourcesbugs", "swbugz", "everythingroses"); } if ($debug) { print STDERR "Attempting to see if bug $bug_id exists\n"; } if (defined $dbh & see_if_bugzilla_bug_exists ($dbh, $bugzillaproduct, $bug_id)) { if ($debug) { print STDERR "It does\n"; } if ($bugzillaproduct ne 'gcc') { mail_bug_notification( sprintf ($MAIL_FORMAT, "sourceware"), "[Bug $bug_id]", @text); } else { mail_bug_notification( sprintf ($MAIL_FORMAT, $bugzillaproduct), "[Bug $bug_id]", @text); } } $dbh->disconnect if defined $dbh; } } } exit 0; --jjBY8MBGA/Y9+Y1H--