Skip to content

Commit

Permalink
fix(create-prs-to-update-vcs-repositories): do not declare logger out…
Browse files Browse the repository at this point in the history
…side of used scope

Signed-off-by: Junya Sasaki <[email protected]>
  • Loading branch information
sasakisasaki committed Sep 5, 2024
1 parent dd45fd1 commit 41d89e0
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@
args = parser.parse_args()


# Initialize logger depending on the verbosity level
if args.verbose == 0:
logging.basicConfig(level=logging.WARNING)
elif args.verbose == 1:
logging.basicConfig(level=logging.INFO)
elif args.verbose >= 2:
logging.basicConfig(level=logging.DEBUG)


logger = logging.getLogger(__name__)


class AutowareRepos:
"""
This class gets information from autoware.repos and updates it
Expand Down Expand Up @@ -171,6 +159,18 @@ def create_pull_request(self, repo_name: str, title: str, body: str, head: str,
base=base,
)

def get_logger(verbose: int) -> logging.Logger:

# Initialize logger depending on the verbosity level
if verbose == 0:
logging.basicConfig(level=logging.WARNING)
elif verbose == 1:
logging.basicConfig(level=logging.INFO)
elif verbose >= 2:
logging.basicConfig(level=logging.DEBUG)

return logging.getLogger(__name__)


def get_latest_tag(tags: list[str], current_version: str) -> Optional[str]:
'''
Expand Down Expand Up @@ -199,7 +199,7 @@ def get_latest_tag(tags: list[str], current_version: str) -> Optional[str]:
return latest_tag


def create_one_branch(repo: git.Repo, branch_name: str) -> bool:
def create_one_branch(repo: git.Repo, branch_name: str, logger: logging.Logger) -> bool:

# Check if the branch already exists
if branch_name in repo.heads:
Expand All @@ -214,6 +214,9 @@ def create_one_branch(repo: git.Repo, branch_name: str) -> bool:

def main(args: argparse.Namespace) -> None:

# Get logger
logger = get_logger(args.verbose)

# Get GitHub token
github_token: str = os.getenv("GITHUB_TOKEN", default=None)
if github_token == "None":
Expand Down Expand Up @@ -282,7 +285,7 @@ def main(args: argparse.Namespace) -> None:
continue

# First, create a branch
create_one_branch(repo, branch_name)
create_one_branch(repo, branch_name, logger)

# Switch to the branch
repo.heads[branch_name].checkout()
Expand Down

0 comments on commit 41d89e0

Please sign in to comment.