Skip to content

Commit

Permalink
Refactor VCS paths out of _util into vcs
Browse files Browse the repository at this point in the history
Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
  • Loading branch information
carmenbianca committed Oct 24, 2024
1 parent 9582ce4 commit 9f9f413
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
7 changes: 0 additions & 7 deletions src/reuse/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import logging
import os
import shutil
import subprocess
from hashlib import sha1
from inspect import cleandoc
Expand All @@ -25,12 +24,6 @@

from .types import StrPath

GIT_EXE = shutil.which("git")
HG_EXE = shutil.which("hg")
JUJUTSU_EXE = shutil.which("jj")
PIJUL_EXE = shutil.which("pijul")


# REUSE-IgnoreStart


Expand Down
15 changes: 7 additions & 8 deletions src/reuse/vcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,25 @@

import logging
import os
import shutil
from abc import ABC, abstractmethod
from inspect import isclass
from pathlib import Path
from typing import TYPE_CHECKING, Generator, Optional, Type

from ._util import (
GIT_EXE,
HG_EXE,
JUJUTSU_EXE,
PIJUL_EXE,
execute_command,
relative_from_root,
)
from ._util import execute_command, relative_from_root
from .types import StrPath

if TYPE_CHECKING:
from .project import Project

_LOGGER = logging.getLogger(__name__)

GIT_EXE = shutil.which("git")
HG_EXE = shutil.which("hg")
JUJUTSU_EXE = shutil.which("jj")
PIJUL_EXE = shutil.which("pijul")


class VCSStrategy(ABC):
"""Strategy pattern for version control systems."""
Expand Down
13 changes: 2 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,9 @@
except ImportError:
sys.path.append(os.path.join(Path(__file__).parent.parent, "src"))
finally:
from reuse._util import (
GIT_EXE,
HG_EXE,
JUJUTSU_EXE,
PIJUL_EXE,
setup_logging,
)
from reuse._util import setup_logging
from reuse.global_licensing import ReuseDep5
from reuse.vcs import GIT_EXE, HG_EXE, JUJUTSU_EXE, PIJUL_EXE

CWD = Path.cwd()

Expand Down Expand Up @@ -117,7 +112,6 @@ def optional_git_exe(
"""Run the test with or without git."""
exe = GIT_EXE if request.param else ""
monkeypatch.setattr("reuse.vcs.GIT_EXE", exe)
monkeypatch.setattr("reuse._util.GIT_EXE", exe)
yield exe


Expand All @@ -136,7 +130,6 @@ def optional_hg_exe(
"""Run the test with or without mercurial."""
exe = HG_EXE if request.param else ""
monkeypatch.setattr("reuse.vcs.HG_EXE", exe)
monkeypatch.setattr("reuse._util.HG_EXE", exe)
yield exe


Expand All @@ -155,7 +148,6 @@ def optional_jujutsu_exe(
"""Run the test with or without Jujutsu."""
exe = JUJUTSU_EXE if request.param else ""
monkeypatch.setattr("reuse.vcs.JUJUTSU_EXE", exe)
monkeypatch.setattr("reuse._util.JUJUTSU_EXE", exe)
yield exe


Expand All @@ -174,7 +166,6 @@ def optional_pijul_exe(
"""Run the test with or without Pijul."""
exe = PIJUL_EXE if request.param else ""
monkeypatch.setattr("reuse.vcs.PIJUL_EXE", exe)
monkeypatch.setattr("reuse._util.PIJUL_EXE", exe)
yield exe


Expand Down

0 comments on commit 9f9f413

Please sign in to comment.