From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 165F83982032 for ; Fri, 30 Jul 2021 19:22:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 165F83982032 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-200-8RAJHURnNGqPiQaF1bS6sA-1; Fri, 30 Jul 2021 15:22:42 -0400 X-MC-Unique: 8RAJHURnNGqPiQaF1bS6sA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B202F8799E0 for ; Fri, 30 Jul 2021 19:22:41 +0000 (UTC) Received: from guittard.redhat.com (ovpn-113-52.phx2.redhat.com [10.3.113.52]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87A9360C17 for ; Fri, 30 Jul 2021 19:22:41 +0000 (UTC) From: Keith Seitz To: bunsen@sourceware.org Subject: [PATCH] Fix Bunsen.testrun(commit_id) Date: Fri, 30 Jul 2021 12:22:41 -0700 Message-Id: <20210730192241.3490696-1-keiths@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: bunsen@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Bunsen mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jul 2021 19:22:45 -0000 The recent refactor commit a69fcff1 broke clients calling Bunsen.testrun with a commit ID: $ ./bunsen.py +summarize 60231993624ee6fa5ced3c8f4ae13bdeda3a94cf Using branch index, checkout name wd-summarize Running summarize at .../bunsen/.bunsen/wd-summarize from .../bunsen/scripts-main/summarize.py with ['60231993624ee6fa5ced3c8f4ae13bdeda3a94cf'] === Traceback (most recent call last): File ".../bunsen/scripts-main/summarize.py", line 40, in testrun = b.testrun(opts.commit) File ".../bunsen/bunsen/repo.py", line 906, in testrun candidate_branches.append(testrun_summary.bunsen_testruns_branch) AttributeError: 'NoneType' object has no attribute 'bunsen_testruns_branch' This is occurring because the code attempts to use `testrun_summary' in a place where it is undefined: if project is None and extra_info is not None \ and 'bunsen_testruns_branch' in extra_info: testrun_project, testrun_year_month, testrun_extra_label = \ extra_info.commit_tag() project = testrun_project candidate_branches.append(testrun_summary.bunsen_testruns_branch) `testrun_summary' is only defined when `testrun_or_commit_id' is an instance of Testrun. In this case, we have a string representing the commit ID. Since `project' is None just before this block, `extra_info' is initialized to a Testrun object. It is this object, therefore, in which we should look for `bunsen_testruns_branch'. This fixes scripts-master/summarize.py. --- bunsen/repo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bunsen/repo.py b/bunsen/repo.py index bc0b982..4d11a87 100644 --- a/bunsen/repo.py +++ b/bunsen/repo.py @@ -903,7 +903,7 @@ class Bunsen: testrun_project, testrun_year_month, testrun_extra_label = \ extra_info.commit_tag() project = testrun_project - candidate_branches.append(testrun_summary.bunsen_testruns_branch) + candidate_branches.append(extra_info.bunsen_testruns_branch) # Option 3: get project,year_month from commit message header. if project is None: -- 2.31.1