Add a central function for registering SCMTools in the database.

Review Request #11338 — Created Dec. 17, 2020 and submitted

Information

Review Board
release-4.0.x

Reviewers

This replaces the core logic from the registerscmtools management
command with a call to a new Tool.objects.register_from_entrypoints()
method. This method does the work of looking for any entrypoint-provided
SCMTools not already in the database, and registers them.

The new implementation executes fewer queries, and slims down the query
for the initial lookup of tools. The management command is also less
verbose, providing a single-line summary after registration instead of a
one line per tool.

Tested the registerscmtools command with registering 1 SCMTool, many
SCMTools, and no SCMTools.

Summary ID
Add a central function for registering SCMTools in the database.
This replaces the core logic from the `registerscmtools` management command with a call to a new `Tool.objects.register_from_entrypoints()` method. This method does the work of looking for any entrypoint-provided SCMTools not already in the database, and registers them. The new implementation executes fewer queries, and slims down the query for the initial lookup of tools. The management command is also less verbose, providing a single-line summary after registration instead of a one line per tool.
c85b4445e9acd6f350973baa83a27e896520436a
Description From Last Updated

F821 undefined name '_'

reviewbotreviewbot

Totally your call, but personally I feel like a better wrapping would be: new_tools.append( self.model(name=name, class_name=class_name))

daviddavid
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. 
      
  2. reviewboard/scmtools/managers.py (Diff revision 2)
     
     
     
    Show all issues

    Totally your call, but personally I feel like a better wrapping would be:

    new_tools.append(
        self.model(name=name, class_name=class_name))
    
    1. I try to keep one keyword argument per line when filing out things like a model, for the same reason we do with dictionaries.

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-4.0.x (5b9703c)
Loading...