Skip to content

Commit e6749b8

Browse files
authored
Merge pull request #2 from oadultradeepfield/feat/add-squash-to-merge-step
Allow squash merge in the merge step
2 parents 149e2f0 + c633f56 commit e6749b8

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "repo-smith"
7-
version = "0.10.1"
7+
version = "0.11.0"
88
authors = [{ name = "Jiahao, Woo", email = "woojiahao1234@gmail.com" }]
99
description = "YAML-based configuration for initializing Git repositories for unit testing"
1010
readme = "README.md"

src/repo_smith/initialize_repo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ def __parse_step(self, step: Any) -> Step:
278278
id=id,
279279
branch_name=step.get("branch-name"),
280280
no_fast_forward=step.get("no-ff", False),
281+
squash=step.get("squash", False),
281282
)
282283
elif step_type == StepType.REMOTE:
283284
if "remote-url" not in step:

src/repo_smith/steps/merge_step.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
class MergeStep(Step):
1010
branch_name: str
1111
no_fast_forward: bool
12+
squash: bool
1213

1314
def execute(self, repo: Repo) -> None:
14-
if self.no_fast_forward:
15-
repo.git.merge(self.branch_name, "--no-edit", "--no-ff")
16-
else:
17-
repo.git.merge(self.branch_name, "--no-edit")
15+
merge_args = [self.branch_name, "--no-edit"]
16+
17+
if self.squash:
18+
merge_args.append("--squash")
19+
elif self.no_fast_forward:
20+
merge_args.append("--no-ff")
21+
22+
repo.git.merge(*merge_args)
23+
24+
if self.squash:
25+
repo.git.commit("-m", f"Squash merge branch '{self.branch_name}'")

0 commit comments

Comments
 (0)