Skip to content

Commit a957ac8

Browse files
committed
feat(config init): added .gitignore creation in .ash directory if config is initialized
1 parent ab95cbe commit a957ac8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

automated_security_helper/cli/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def init(
3636
str,
3737
typer.Argument(
3838
help=f"The name of the config file to initialize. By default, ASH looks for the following config file names in the source directory of a scan: {ASH_CONFIG_FILE_NAMES}. If a different filename is specified, it must be provided when running ASH via the `--config` option or by setting the `ASH_CONFIG` environment variable.",
39+
envvar="ASH_CONFIG",
3940
),
4041
] = ".ash/.ash.yaml",
4142
force: Annotated[
@@ -60,6 +61,15 @@ def init(
6061
fg=typer.colors.RED,
6162
)
6263
raise typer.Exit(1)
64+
config_path_path.parent.mkdir(exist_ok=True, parents=True)
65+
if config_path_path.parent.name == ".ash":
66+
ash_gitignore_path = config_path_path.parent.joinpath(".gitignore")
67+
if not ash_gitignore_path.exists():
68+
ash_gitignore_path.write_text(
69+
"# ASH default output directory (and variants)"
70+
)
71+
ash_gitignore_path.write_text("ash_output*")
72+
ash_gitignore_path.write_text("")
6373
typer.secho(f"Saving ASH config to path: {config_path_path.absolute()}")
6474
config = AshConfig(
6575
project_name=config_path_path.absolute().parent.name,

0 commit comments

Comments
 (0)