Skip to content

Commit 8d5736d

Browse files
Add --no-subdir flag to create the dummy Git repo in the current
directory Signed-off-by: Jacob Stopak <[email protected]>
1 parent 9bc6e4e commit 8d5736d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Available options and flags include:
6565
`--diverge-at`: The commit number at which branches diverge from `main`.
6666
`--merge`: A comma separated list of branch postfix ids to merge back into `main`.
6767
`--git-dir`: The path at which to store the dummy Git repo, defaults to current directory.
68+
`--no-subdir`: Initialize the dummy Git repo in the current directory instead of in a subdirectory.
6869

6970
## Command examples
7071
Generate a dummy Git repo called "cheese" on your Desktop, with 2 branches and 10 commits on each branch:

git_dummy/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,21 @@ def main(
3535
settings.merge,
3636
help="Comma separated branch ids to merge back into main",
3737
),
38+
no_subdir: bool = typer.Option(
39+
settings.no_subdir,
40+
help="Initialize the dummy Git repo in the current directory instead of in a subdirectory",
41+
),
3842
):
3943
settings.name = name
40-
settings.git_dir = os.path.join(os.path.expanduser(git_dir), name)
4144
settings.commits = commits
4245
settings.branches = branches
4346
settings.diverge_at = diverge_at
4447
settings.merge = merge
48+
settings.no_subdir = no_subdir
49+
50+
settings.git_dir = os.path.expanduser(git_dir)
51+
if not settings.no_subdir:
52+
settings.git_dir = os.path.join(settings.git_dir, settings.name)
4553

4654
repo = git.Repo.init(settings.git_dir)
4755
repo.config_writer().set_value("init", "defaultBranch", "main").release()

git_dummy/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Settings(BaseSettings):
99
branches = 1
1010
diverge_at = 0
1111
merge = ""
12+
no_subdir = False
1213

1314
class Config:
1415
env_prefix = "git_dummy_"

0 commit comments

Comments
 (0)