Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/sc/branching/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class BranchType(str, Enum):
def __str__(self):
return self.value

@staticmethod
def is_valid(value: str) -> bool:
try:
BranchType(value)
return True
except ValueError:
return False

@dataclass
class Branch:
type: BranchType
Expand Down
15 changes: 6 additions & 9 deletions src/sc/branching/branching.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .commands.checkout import Checkout
from .commands.clean import Clean
from .commands.command import Command
from .commands.finish import Finish, FinishOperationError
from .commands.finish import Finish
from .commands.init import Init
from .commands.list import List
from .commands.pull import Pull
Expand All @@ -39,6 +39,7 @@
logger = logging.getLogger(__name__)

class ProjectType(Enum):
"""Git or repo."""
GIT = "git"
REPO = "repo"

Expand Down Expand Up @@ -133,14 +134,10 @@ def finish(
):
top_dir, project_type = detect_project(run_dir)
branch = create_branch(project_type, top_dir, branch_type, name)
try:
run_command_by_project_type(
Finish(top_dir, branch, base),
project_type
)
except FinishOperationError as e:
logger.error(e)
sys.exit(1)
run_command_by_project_type(
Finish(top_dir, branch, base),
project_type
)

@staticmethod
def list(branch_type: BranchType, run_dir: Path = Path.cwd()):
Expand Down
Loading