Commit a0814195 authored by Thomas de Grenier de Latour's avatar Thomas de Grenier de Latour
Browse files

Merge branch 'main' into more-options

parents 2b0b7891 21eb20a5
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
## [1.1.8](https://gitlab.com/to-be-continuous/tools/gitlab-cp/compare/1.1.7...1.1.8) (2024-06-30)


### Bug Fixes

* fix insecure on avatar by replace urlretrieve by requests.get ([610c1a7](https://gitlab.com/to-be-continuous/tools/gitlab-cp/commit/610c1a79f3f597b2cd8cf9c342edcb10d8fa8c02)), closes [#3](https://gitlab.com/to-be-continuous/tools/gitlab-cp/issues/3)

## [1.1.7](https://gitlab.com/to-be-continuous/tools/gitlab-cp/compare/1.1.6...1.1.7) (2024-05-31)


+16 −15
Original line number Diff line number Diff line
@@ -2,13 +2,12 @@ import argparse
import json
import os
import shutil
import ssl
from enum import Enum
from logging import Logger
from pathlib import Path
from typing import Optional, Union
from urllib.request import urlretrieve

import requests
from git import GitError, Repo
from gitlab import (
    Gitlab,
@@ -47,11 +46,6 @@ class AnsiColors:
    UNDERLINE = "\033[4m"


INSECURE_SSL_CTX = ssl.create_default_context()
INSECURE_SSL_CTX.check_hostname = False
INSECURE_SSL_CTX.verify_mode = ssl.CERT_NONE


class GlVisibility(str, Enum):
    """GitLab project visibility."""

@@ -81,6 +75,7 @@ class Synchronizer:
        dry_run=True,
        continue_on_error=False,
        update_avatar=False,
        ssl_verify=True,
        new_project_options={},
        new_group_options={},
    ):
@@ -99,6 +94,7 @@ class Synchronizer:
        self.dry_run = dry_run
        self.continue_on_error = continue_on_error
        self.force_update_avatar = update_avatar
        self.ssl_verify = ssl_verify
        self.errors: list[Exception] = []
        self.warnings: list[Exception] = []
        self.groups_count = 0
@@ -388,7 +384,9 @@ class Synchronizer:
    # Synchronizes a GitLab project
    # $1: source project JSON
    # $2: destination parent group ID (number)
    def sync_project(self, src_project: Project, dest_parent_group: Optional[Group]) -> None:
    def sync_project(
        self, src_project: Project, dest_parent_group: Optional[Group]
    ) -> None:
        dest_project_path = self.to_dest_path(src_project.path_with_namespace)
        print(
            f"  - 🏠 Project {AnsiColors.BLUE}{src_project.path_with_namespace}{AnsiColors.RESET} ({src_project.get_id()}) => {AnsiColors.BLUE}{dest_project_path}{AnsiColors.RESET}..."
@@ -400,7 +398,9 @@ class Synchronizer:
        dest_project: Optional[Project] = None

        # 1: sync project
        dest_visibility = self.adjust_visibility(src_project.attributes.get("visibility", GlVisibility.public))
        dest_visibility = self.adjust_visibility(
            src_project.attributes.get("visibility", GlVisibility.public)
        )
        try:
            dest_project = self.dest_client.projects.get(dest_project_path)
            changed_attr = []
@@ -510,9 +510,9 @@ class Synchronizer:
            )
        else:
            try:
                avatar_path = self.work_dir / basename(src_avatar_url)
                urlretrieve(src_avatar_url, avatar_path)
                dest_project.avatar = open(avatar_path, "rb")
                dest_project.avatar = requests.get(
                    src_avatar_url, verify=self.ssl_verify
                ).content
                dest_project.save()
                print(
                    f"    - avatar image: {AnsiColors.HYELLOW}updated{AnsiColors.RESET} ({src_avatar_url})"
@@ -678,9 +678,9 @@ class Synchronizer:
            )
        else:
            try:
                avatar_path = self.work_dir / basename(src_avatar_url)
                urlretrieve(src_avatar_url, avatar_path)
                dest_group.avatar = open(avatar_path, "rb")
                dest_group.avatar = requests.get(
                    src_avatar_url, verify=self.ssl_verify
                ).content
                dest_group.save()
                print(
                    f"- avatar image: {AnsiColors.HYELLOW}updated{AnsiColors.RESET} ({src_avatar_url})"
@@ -1060,6 +1060,7 @@ def run() -> None:
        dry_run=args.dry_run,
        continue_on_error=not args.halt_on_error,
        update_avatar=args.update_avatar,
        ssl_verify=not args.insecure,
        new_group_options=new_group_options,
        new_project_options=new_project_options,
    )
+117 −116

File changed.

Preview size limit exceeded, changes collapsed.

+3 −2
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "gitlab-cp"
version = "1.1.7"
version = "1.1.8"
description = "GitLab Copy CLI"
authors = ["Pierre Smeyers <pierre.smeyers@gmail.com>"]
license = "LGPL"
@@ -18,6 +18,7 @@ gitlab-cp = "gitlab_cp.sync:run"
python = "^3.11"
python-gitlab = "^4.4.0"
gitpython = "^3.1.43"
requests = "^2.32.3"

[tool.poetry.group.dev.dependencies]
# new development dependencies can be added with 'poetry add -D yyy'
@@ -25,7 +26,7 @@ pytest = "^8.0.0"
pytest-cov = "^4.0.0"
pytest-env = "^1.0.0"
mypy = "^1.0.0"
ruff = "^0.4.1"
ruff = "^0.5.0"

[tool.pytest.ini_options]
# this project uses "pytest" for unit testing