datasecops-cli 0.7.0b11__tar.gz → 0.7.0b12__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/CHANGELOG.md +26 -0
  2. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/PKG-INFO +1 -1
  3. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/docs/git-operations.md +2 -0
  4. datasecops_cli-0.7.0b12/docs/squash-merge-into-test-review.md +172 -0
  5. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/pyproject.toml +1 -1
  6. datasecops_cli-0.7.0b12/src/datasecops_cli/__init__.py +1 -0
  7. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/main.py +5 -1
  8. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/configuration.py +2 -55
  9. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/development.py +20 -24
  10. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/git_operations.py +61 -34
  11. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/models/project_config.py +21 -1
  12. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dbt_project_generator.py +18 -13
  13. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/download_service.py +10 -4
  14. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/git_service.py +58 -45
  15. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/server.py +14 -1
  16. datasecops_cli-0.7.0b12/tests/test_git_operations_menu.py +58 -0
  17. datasecops_cli-0.7.0b12/tests/test_git_service.py +130 -0
  18. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_main.py +35 -0
  19. datasecops_cli-0.7.0b12/tests/test_mcp_branching_rules.py +74 -0
  20. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_models.py +25 -0
  21. datasecops_cli-0.7.0b11/src/datasecops_cli/__init__.py +0 -1
  22. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/.github/workflows/auto-tag.yml +0 -0
  23. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/.github/workflows/publish-cli.yml +0 -0
  24. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/.github/workflows/test.yml +0 -0
  25. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/.gitignore +0 -0
  26. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/AGENTS.md +0 -0
  27. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/DEVELOPMENT.md +0 -0
  28. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/LICENSE +0 -0
  29. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/README.md +0 -0
  30. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/docs/dcm.md +0 -0
  31. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/docs/getting-started.md +0 -0
  32. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/docs/legacy.md +0 -0
  33. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/docs/legacy_plan_of_action.md +0 -0
  34. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/docs/mcp-server.md +0 -0
  35. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/mcp-servers.json +0 -0
  36. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/scripts/vendor_model.py +0 -0
  37. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/setup.ps1 +0 -0
  38. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/setup.sh +0 -0
  39. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/config.py +0 -0
  40. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/__init__.py +0 -0
  41. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/dcm_operations.py +0 -0
  42. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/menus/downloads.py +0 -0
  43. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/models/__init__.py +0 -0
  44. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/models/git_helpers.py +0 -0
  45. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/__init__.py +0 -0
  46. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/bootstrap_service.py +0 -0
  47. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dbt_runner.py +0 -0
  48. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_orchestrator.py +0 -0
  49. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_pipelines.py +0 -0
  50. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_registry.py +0 -0
  51. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/dcm_service.py +0 -0
  52. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/directory_scaffolder.py +0 -0
  53. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/linting_service.py +0 -0
  54. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/model_commands.py +0 -0
  55. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/pipeline_env.py +0 -0
  56. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/skill_service.py +0 -0
  57. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/snowflake_service.py +0 -0
  58. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/services/upstream_service.py +0 -0
  59. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/__init__.py +0 -0
  60. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/display.py +0 -0
  61. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/file_utils.py +0 -0
  62. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/mcp.py +0 -0
  63. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_cli/utilities/yaml_utils.py +0 -0
  64. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/__init__.py +0 -0
  65. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/__main__.py +0 -0
  66. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_mcp/connection.py +0 -0
  67. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/__init__.py +0 -0
  68. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/convert.py +0 -0
  69. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/diagram.py +0 -0
  70. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/expand.py +0 -0
  71. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/extract.py +0 -0
  72. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/render.py +0 -0
  73. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/schema.py +0 -0
  74. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/scope.py +0 -0
  75. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/scripts.py +0 -0
  76. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/starter.py +0 -0
  77. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/templates/macros/role.sql +0 -0
  78. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/templates/macros/role_guard.sql +0 -0
  79. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/templates/macros/warehouse.sql +0 -0
  80. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/src/datasecops_model/validate.py +0 -0
  81. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/__init__.py +0 -0
  82. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_config.py +0 -0
  83. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_dbt_project_generator_profiles.py +0 -0
  84. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_dbt_runner.py +0 -0
  85. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_dcm_model.py +0 -0
  86. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_dcm_orchestrator.py +0 -0
  87. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_dcm_service.py +0 -0
  88. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_download_service.py +0 -0
  89. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_file_utils.py +0 -0
  90. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_linting_service.py +0 -0
  91. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_mcp_lint_tools.py +0 -0
  92. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_model_commands.py +0 -0
  93. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_pipeline_env.py +0 -0
  94. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_version.py +0 -0
  95. {datasecops_cli-0.7.0b11 → datasecops_cli-0.7.0b12}/tests/test_yaml_utils.py +0 -0
@@ -2,6 +2,32 @@
2
2
 
3
3
  All notable changes to the DataSecOps CLI are documented in this file.
4
4
 
5
+ ## [Unreleased]
6
+
7
+ ### Fixed
8
+
9
+ - **`download packages` ignored upstream package exclusion for downstream projects with no packages of their own** — `download_dbt_packages()`'s upstream-exclusion filter was nested inside `if profile.dbt_packages:`, so a downstream project relying entirely on an upstream project (empty `dbt_packages`) skipped filtering altogether and got the full, unfiltered package list instead of excluding what the upstream project already provides. The same bug existed in the unused `generate_packages_yml()`. Both now compute the enabled set independently of whether `dbt_packages` is empty, then subtract upstream packages regardless.
10
+ - **Configurable branch names (PR review follow-ups):**
11
+ - Legacy `main`/`test`/`prod` branches could leak through as selectable deploy/reset targets when a project configured different trunk/integration/production names but its `deployment_branches`/`environments` still carried the old literal names. `_deploy()` and `_reset_branch_from_main()` now always exclude the legacy defaults in addition to the configured names.
12
+ - A blank or `null` `trunk_branch`/`integration_branch`/`production_branch` in the native app's `SOURCE_CONTROL` config previously produced invalid branch refs (e.g. `origin/`) or aborted config loading entirely; `SourceControl` now falls back to the documented default for any blank/null value.
13
+ - `get_test_file_conflicts()`/`get_test_commits()` parsed a squash-merge commit's source branch by stripping `" into {current integration_branch}"` from its message — after renaming `integration_branch`, historical commits (which still say `" into {old name}"`) were misparsed, could be misclassified as stale, and silently force-removed from the integration branch. Parsing now splits on the last `" into "` separator, independent of the currently configured name.
14
+ - The MCP server's `get_branching_rules` omitted `trunk_branch`/`integration_branch`/`production_branch`; it now includes them (falling back to defaults for blank/null values).
15
+ - Git Operations menu labels and confirmations (`rebase`, `squash to test`, `remove from test`, `deploy to prod`, `reset branch`, and their confirmation/error text) now use the configured branch names instead of hardcoded `main`/`test`.
16
+
17
+ ## [0.7.0b12] - 2026-11-02
18
+
19
+ ### Added
20
+
21
+ - **Git deploy/trunk/integration branch names are configurable** — `SourceControl` gains `trunk_branch` (default `"main"`), `integration_branch` (default `"test"`), and `production_branch` (default `"prod"`), read from the native app's `SOURCE_CONTROL` framework config. `GitService` and the Git Operations menu (deploy, deploy to prod, squash to test, remove from test, reset branch, cleanup, delete branch) now use these settings instead of hardcoded `"main"`/`"test"`/`"prod"` literals. Existing projects keep working unchanged since the defaults match the old hardcoded values.
22
+
23
+ ### Changed
24
+
25
+ - **Lint menu merges find/fix pairs into single prompts** — the "find modified"/"fix modified" and "find all"/"fix all" option pairs are now one "modified" (or "changed" on dbt2, replacing the old separate "changed" option) and one "all" option each, asking "Also auto-fix the issues found?" instead of needing two separate menu entries.
26
+
27
+ ### Removed
28
+
29
+ - **Configuration menu's `dbt engine` and `upgrade dbt` options** — removed `[6] dbt engine` (local `.datasecops.yml` toggle between `dbt2`/`dbt_core`) and `[7] upgrade dbt` (unpinned `pip install --upgrade dbt`, dbt2 only). The engine toggle duplicated the framework's `PROJECT` config (which is already the source of truth for `dbt_engine`), and `upgrade dbt` bypassed the framework's pinned dbt version instead of going through `[1] install dbt`.
30
+
5
31
  ## [0.7.0b11] - 2026-11-01
6
32
 
7
33
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: datasecops-cli
3
- Version: 0.7.0b11
3
+ Version: 0.7.0b12
4
4
  Summary: DataSecOps Framework CLI for Snowflake Native App
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -2,6 +2,8 @@
2
2
 
3
3
  The CLI provides a structured git workflow designed around a branching strategy where feature branches are squash-merged into a `test` branch for integration testing, and only `main` is deployed to production.
4
4
 
5
+ > The `main`/`test`/`prod` branch names below are the defaults. They're configurable via the native app's `SOURCE_CONTROL` framework config (`trunk_branch`, `integration_branch`, `production_branch`) — set those if your project uses different branch names (e.g. `trunk`/`staging`/`release`).
6
+
5
7
  ## Branch Strategy
6
8
 
7
9
  ```
@@ -0,0 +1,172 @@
1
+ # Review: "Squash Merge into Test" Functionality
2
+
3
+ This is a code-level review of what `datasecops`'s "squash to test" / "remove from test" Git
4
+ Operations actually do, as implemented today in `src/datasecops_cli/services/git_service.py`
5
+ and `src/datasecops_cli/menus/git_operations.py`. It traces the exact sequence of git commands
6
+ run, not just the intended design.
7
+
8
+ Branch names used below assume the defaults (`main` trunk, `test` integration branch), which are
9
+ now configurable via `SourceControl.trunk_branch` / `SourceControl.integration_branch` — see
10
+ [`docs/git-operations.md`](git-operations.md). Everywhere `test` is written below, read it as
11
+ "the configured integration branch", and `main` as "the configured trunk branch".
12
+
13
+ ## What it's for
14
+
15
+ Feature/bugfix/hotfix branches are built from `main`. Instead of merging each one into `main`
16
+ directly, they're **squash-merged into a shared `test` branch** so multiple branches' changes can
17
+ be integration-tested together on Snowflake before anything reaches production. `test` is never
18
+ merged back into `main` — `main` only ever gets deployed to prod directly, from its own commits.
19
+ `test` is a disposable, force-pushed scratch branch whose entire history is rebuilt from `main` on
20
+ every squash merge.
21
+
22
+ ## Entry point: `GitOperationsMenu._squash_merge_test()`
23
+
24
+ (`menus/git_operations.py:246-281`)
25
+
26
+ This is menu option `[7] squash to test`. It runs three checks *before* calling
27
+ `GitService.squash_merge_into_test()`, and the checks are where most of the actual safety logic
28
+ lives — `squash_merge_into_test()` itself does no validation at all.
29
+
30
+ ### Check 1 — your branch must be up to date with `main`
31
+
32
+ `GitService.is_branch_up_to_date_with_main()` (`git_service.py:223-232`):
33
+
34
+ ```python
35
+ self.repo.remotes.origin.fetch()
36
+ merge_base = self.repo.git.merge_base("HEAD", f"origin/{self.trunk_branch}")
37
+ main_sha = self.repo.commit(f"origin/{self.trunk_branch}").hexsha
38
+ return merge_base.strip() == main_sha
39
+ ```
40
+
41
+ This checks that `origin/main`'s tip is an ancestor of `HEAD` — i.e. your branch already contains
42
+ every commit on `main`. If not, the menu rejects the merge outright ("Rebase with main first")
43
+ and nothing further happens. This is the only thing standing between your branch and a squash
44
+ merge; if you're behind main but a rebase isn't forced, nothing re-checks this later.
45
+
46
+ ### Check 2 — file-overlap detection against what's currently on `test`
47
+
48
+ `GitService.get_test_file_conflicts()` (`git_service.py:320-363`):
49
+
50
+ 1. Fetches, then diffs your branch against `origin/main` (`git diff --name-only origin/main...HEAD`)
51
+ to get the set of files *you've* touched.
52
+ 2. Walks the last 100 commits on `origin/test`, looking only at commits whose message starts with
53
+ `"squash merge:"` — i.e. commits this same tool produced.
54
+ 3. For each such commit, parses out which branch it came from by string-manipulating the commit
55
+ message (see **Known issue** below), and diffs that single commit's tree
56
+ (`git diff-tree --no-commit-id --name-only -r <sha>`) to get the files *it* touched.
57
+ 4. If your files and that commit's files intersect, it's a "conflict" — recorded with the other
58
+ branch's name, its commit SHA, the overlapping files, and whether that branch still exists on
59
+ the remote (checked against `origin`'s current branch list).
60
+
61
+ Back in the menu, conflicts split into two buckets:
62
+
63
+ - **Active conflict** (the other branch still exists remotely): the merge is **rejected**. You're
64
+ told to resolve it with the branch owner or remove their branch from `test` first. Nothing is
65
+ mutated.
66
+ - **Stale conflict** (the other branch no longer exists remotely — e.g. it was merged to main and
67
+ deleted): the menu automatically calls `revert_from_test()` to drop that old commit from `test`
68
+ before proceeding, with a warning printed. This happens silently as part of "squash to test" —
69
+ there's no separate confirmation for this specific removal.
70
+
71
+ ### Check 3 — final user confirmation, then the actual merge
72
+
73
+ Only after both checks pass does the menu ask "Continue?" and, if yes, call
74
+ `squash_merge_into_test()`.
75
+
76
+ ## The merge itself: `GitService.squash_merge_into_test()`
77
+
78
+ (`git_service.py:234-272`)
79
+
80
+ Step by step:
81
+
82
+ 1. **Stash** any uncommitted changes in the working tree (`git stash push -u`), remembering
83
+ whether anything was stashed.
84
+ 2. **Fetch** from origin.
85
+ 3. **Checkout `test`** via `_checkout_test()` (`git_service.py:213-221`), which:
86
+ - tries `git checkout test` (works if you already have a local `test` branch),
87
+ - else creates it from `origin/test` (`git checkout -b test origin/test`),
88
+ - else — if `origin/test` doesn't exist yet at all — creates it from `origin/main` instead.
89
+ 4. **Pull** `test` (best-effort — failure here is silently swallowed; a brand-new local branch
90
+ with no upstream will fail this pull and that's expected/fine).
91
+ 5. **Rebase `test` onto `origin/main`** (`git rebase origin/main`). This is the step that keeps
92
+ `test`'s base in sync with `main` — `test` always ends up looking like "main + all currently
93
+ active squash commits", never drifting from main's latest state.
94
+ 6. **Squash-merge your branch into `test`** (`git merge --squash <current-branch>`) — stages your
95
+ branch's full diff without creating a merge commit.
96
+ 7. **Commit** with message `"squash merge: {your-branch} into {test}"`. This exact string format
97
+ is load-bearing: it's how `get_test_commits()` and `get_test_file_conflicts()` later identify
98
+ which commits on `test` came from which feature branch.
99
+ 8. **Force-push `test`** (`git push test --set-upstream --force`). Force is required because step
100
+ 5 just rewrote `test`'s history via rebase.
101
+ 9. **Checkout back to your original branch** and **pop the stash** if one was made.
102
+
103
+ ### On any `GitCommandError` during the above
104
+
105
+ - Abort any in-progress rebase (`git rebase --abort`, failure ignored).
106
+ - Best-effort checkout back to your original branch.
107
+ - Best-effort stash pop.
108
+ - Return `False`; the menu's `success_line`/`error_line` reporting is based on this.
109
+
110
+ Note the ordering risk here: steps 3–8 all happen on `test` while your original branch sits
111
+ unchecked-out. If the process is killed between step 6 (squash) and step 9 (checkout back), you
112
+ are left on `test` with an uncommitted squash merge staged and your stash (if any) still stashed —
113
+ there's no re-entrant recovery for that specific failure window; it relies on the `except` block
114
+ running, which only triggers on `GitCommandError`, not on e.g. a `KeyboardInterrupt`.
115
+
116
+ ## "Remove from Test": `GitOperationsMenu._cherry_pick_test()` → `revert_from_test()`
117
+
118
+ (`menus/git_operations.py:283-299`, `git_service.py:274-318`)
119
+
120
+ 1. `get_test_commits()` (`git_service.py:365-384`) walks the last 100 commits on `origin/test`,
121
+ filters to ones starting with `"squash merge:"`, and parses out the branch name from each
122
+ message the same way `get_test_file_conflicts()` does.
123
+ 2. The menu lists them (newest-first per git log order) and lets you pick one by number.
124
+ 3. `revert_from_test(sha, branch_name)`:
125
+ - stash / fetch / checkout `test` (same pattern as the merge flow),
126
+ - pull `test` (best-effort),
127
+ - **refuses** if the target commit has more than one parent (i.e. it's not a plain squash
128
+ commit — defends against someone having manually merged something onto `test`),
129
+ - `git rebase --onto <sha>^ <sha> test` — this surgically **drops** that one commit from
130
+ history (not a revert-commit; the commit is gone, as if it never happened), replaying
131
+ everything after it on top of its parent,
132
+ - force-pushes `test`,
133
+ - checks out back to your original branch, pops stash if needed.
134
+
135
+ This is why `test`'s history is disposable: branches are added and removed from it by literally
136
+ rewriting history and force-pushing, never by merge/revert commits.
137
+
138
+ ## Known issue found during this review
139
+
140
+ **Bug: commit-message parsing breaks if `integration_branch` is renamed after commits already
141
+ exist on the old name.**
142
+
143
+ Both `get_test_file_conflicts()` (`git_service.py:346`) and `get_test_commits()`
144
+ (`git_service.py:372`) parse the branch name out of a squash-merge commit message like this:
145
+
146
+ ```python
147
+ other_branch = msg.replace("squash merge: ", "", 1).replace(f" into {self.integration_branch}", "")
148
+ ```
149
+
150
+ This only strips the `" into {integration_branch}"` suffix if it matches the **currently
151
+ configured** `integration_branch`. A commit made *before* a project renamed its integration branch
152
+ (say from `test` to `staging`) has the literal text `"squash merge: feature/orders into test"`
153
+ baked into its message forever (commit messages don't change when you rename branches). After the
154
+ rename, `self.integration_branch` is `"staging"`, so `.replace(" into staging", "")` doesn't match
155
+ `" into test"`, and `other_branch` comes out as `"feature/orders into test"` instead of
156
+ `"feature/orders"`.
157
+
158
+ Concretely, this breaks:
159
+ - The "remove from test" menu — it lists a mangled, unselectable-looking branch name.
160
+ - File-conflict detection — `other_branch == current` can never be true for that old commit (since
161
+ `current` is a real branch name without the `" into test"` suffix), so a conflict against your
162
+ *own* branch's old commit won't be recognized as "skip, that's me." More importantly,
163
+ `other_branch in remote_branches` will be `False` for the mangled name even if the real branch
164
+ still exists, so the commit is misclassified as **stale** and gets auto-removed
165
+ (`revert_from_test`) and force-pushed over on your next squash merge — silently dropping another
166
+ branch's integration-test changes without the "active conflict, rejected" warning that would
167
+ normally protect it.
168
+
169
+ This only manifests after an `integration_branch` rename with pre-existing history on the old
170
+ branch name; it does not affect projects that have never changed `integration_branch` from its
171
+ configured value. Fix direction: parse using the last `" into "` separator in the message
172
+ (independent of the currently configured name), e.g. `msg[len("squash merge: "):].rsplit(" into ", 1)[0]`.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "datasecops-cli"
7
- version = "0.7.0b11"
7
+ version = "0.7.0b12"
8
8
  description = "DataSecOps Framework CLI for Snowflake Native App"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -0,0 +1 @@
1
+ __version__ = "0.7.0b12"
@@ -965,7 +965,11 @@ def _run_interactive(config: Config):
965
965
  )
966
966
 
967
967
  try:
968
- git_service = GitService(config.project_dir)
968
+ git_service = GitService(
969
+ config.project_dir,
970
+ trunk_branch=config.source_control.trunk_branch,
971
+ integration_branch=config.source_control.integration_branch,
972
+ )
969
973
  except Exception:
970
974
  git_service = None
971
975
 
@@ -10,11 +10,10 @@ from datasecops_cli.services.download_service import DownloadService
10
10
  from datasecops_cli.services.linting_service import LintingService
11
11
  from datasecops_cli.utilities.display import (
12
12
  clear, section_header, display_action_header, menu_option,
13
- get_input_number, get_input_true_false, complete_action,
14
- info_line, success_line, warning_line, error_line,
13
+ get_input_number, complete_action,
14
+ info_line, success_line, error_line,
15
15
  get_input_string, select_from_list, select_multiple_from_list
16
16
  )
17
- from datasecops_cli.utilities.yaml_utils import write_datasecops_config
18
17
 
19
18
 
20
19
  class ConfigurationMenu:
@@ -49,16 +48,11 @@ class ConfigurationMenu:
49
48
  complete_action()
50
49
  elif option == 5:
51
50
  self._cortex_upgrade()
52
- elif option == 6:
53
- self._toggle_dbt_engine()
54
- elif option == 7:
55
- self._upgrade_dbt2()
56
51
  self._menu()
57
52
  option = get_input_number("Choose an option: ")
58
53
 
59
54
  def _menu(self) -> None:
60
55
  clear()
61
- engine_label = self.datasecops_config.get_engine_label()
62
56
  is_dbt2 = self.datasecops_config.dbt_engine == "dbt2"
63
57
  section_header("Configuration", self.profile_name)
64
58
  if is_dbt2:
@@ -69,9 +63,6 @@ class ConfigurationMenu:
69
63
  menu_option(3, "mcp servers - Configure MCP servers for AI tools")
70
64
  menu_option(4, "new project - Initialize a new dbt project with framework profiles")
71
65
  menu_option(5, "cortex update - Update CoCo to the latest version")
72
- menu_option(6, f"dbt engine - Switch dbt engine (current: {engine_label})")
73
- if is_dbt2:
74
- menu_option(7, "upgrade dbt - Upgrade dbt 2.0 to the latest version (pip)")
75
66
  menu_option(0, "back - Return to main menu")
76
67
 
77
68
  def _install_dbt_requirements(self) -> None:
@@ -238,47 +229,3 @@ class ConfigurationMenu:
238
229
  except FileNotFoundError:
239
230
  error_line("CoCo CLI not found.")
240
231
  complete_action()
241
-
242
- def _toggle_dbt_engine(self) -> None:
243
- """Toggle between dbt 2.0 and dbt Core (1.x)."""
244
- display_action_header("Switch dbt Engine")
245
- current = self.datasecops_config.dbt_engine or "dbt_core"
246
- info_line(f"Current engine: {self.datasecops_config.get_engine_label()} ({current})")
247
- info_line("")
248
- menu_option(1, "dbt 2.0 - dbt2 (recommended)")
249
- menu_option(2, "dbt Core 1.x - dbt_core")
250
- menu_option(0, "cancel")
251
- option = get_input_number("Choose an option: ")
252
-
253
- if option == 1:
254
- new_engine = "dbt2"
255
- elif option == 2:
256
- new_engine = "dbt_core"
257
- else:
258
- return
259
-
260
- if new_engine == current:
261
- info_line("No change.")
262
- complete_action()
263
- return
264
-
265
- self.datasecops_config.dbt_engine = new_engine
266
- config_data = self.datasecops_config.model_dump(exclude={"VALID_ENGINES"})
267
- write_datasecops_config(self.project_dir, config_data)
268
- success_line(f"dbt engine switched to {self.datasecops_config.get_engine_label()} ({new_engine})")
269
- warning_line("Restart the CLI for the change to take effect.")
270
- complete_action()
271
-
272
- def _upgrade_dbt2(self) -> None:
273
- """Upgrade dbt 2.0 to the latest version via pip."""
274
- display_action_header("Upgrade dbt 2.0")
275
- if not shutil.which("dbt"):
276
- error_line("dbt not found. Install it first.")
277
- complete_action()
278
- return
279
- try:
280
- info_line("Upgrading dbt via uv pip...")
281
- subprocess.run(["uv", "pip", "install", "--upgrade", "dbt"])
282
- except FileNotFoundError:
283
- error_line("uv not found.")
284
- complete_action()
@@ -296,33 +296,32 @@ class DevelopmentMenu:
296
296
  def _lint_menu(self) -> None:
297
297
  clear()
298
298
  is_dbt2 = self.linting.dbt_engine == "dbt2"
299
- lint_label = "dbt lint" if is_dbt2 else "SQLFluff"
300
- display_action_header(f"{lint_label} Linting Options")
301
- menu_option(1, "find modified - Lint modified SQL files")
302
- menu_option(2, "fix modified - Fix modified SQL files")
303
- menu_option(3, "find all - Lint all SQL files")
304
- menu_option(4, "fix all - Fix all SQL files")
305
- menu_option(5, "specific - Lint specific file")
306
- menu_option(6, "refresh config- Re-download .sqlfluff from framework")
299
+ display_action_header("Linting Options")
307
300
  if is_dbt2:
308
- menu_option(7, "changed - Lint only git-changed files (dbt lint --changed)")
309
- menu_option(8, "format - Auto-format SQL files (dbt format/fmt)")
301
+ menu_option(1, "changed - Lint only git-changed files (dbt lint --changed)")
302
+ else:
303
+ menu_option(1, "modified - Lint modified SQL files")
304
+ menu_option(2, "all - Lint all SQL files")
305
+ menu_option(3, "specific - Lint specific file")
306
+ menu_option(4, "refresh config- Re-download .sqlfluff from framework")
307
+ if is_dbt2:
308
+ menu_option(5, "format - Auto-format SQL files (dbt format/fmt)")
310
309
  menu_option(0, "back - Return to development menu")
311
310
  option = get_input_number("Choose an option: ")
312
- if option in (1, 2, 3, 4, 5, 7, 8) and not self._ensure_sqlfluff_config():
311
+ if option in (1, 2, 3, 5) and not self._ensure_sqlfluff_config():
313
312
  complete_action()
314
313
  return
315
314
  if option == 1:
316
- changed = self.git.get_all_modified_files() if self.git else []
317
- self.linting.lint_modified(fix=False, changed_files=changed)
315
+ fix = get_input_true_false("Also auto-fix the issues found?", "n")
316
+ if is_dbt2:
317
+ self.linting.lint_changed(fix=fix)
318
+ else:
319
+ changed = self.git.get_all_modified_files() if self.git else []
320
+ self.linting.lint_modified(fix=fix, changed_files=changed)
318
321
  elif option == 2:
319
- changed = self.git.get_all_modified_files() if self.git else []
320
- self.linting.lint_modified(fix=True, changed_files=changed)
322
+ fix = get_input_true_false("Also auto-fix the issues found?", "n")
323
+ self.linting.lint_file(fix=fix)
321
324
  elif option == 3:
322
- self.linting.lint_file(fix=False)
323
- elif option == 4:
324
- self.linting.lint_file(fix=True)
325
- elif option == 5:
326
325
  name = get_input_string("Enter model name or file path (e.g. stg_orders): ")
327
326
  if name != "0":
328
327
  path = name if name.endswith(".sql") else self.linting.resolve_model_path(name)
@@ -343,15 +342,12 @@ class DevelopmentMenu:
343
342
  jinja_render_mode=jinja_render_mode)
344
343
  else:
345
344
  error_line(f"Could not find model '{name}' in models/ directory")
346
- elif option == 6:
345
+ elif option == 4:
347
346
  if not self.downloads:
348
347
  error_line("Download service not available")
349
348
  else:
350
349
  self.downloads.download_sqlfluff_config(profiles_dir=self.profiles_dir, dbt_project_dir=self.linting.project_dir)
351
- elif option == 7 and is_dbt2:
352
- fix = get_input_true_false("Also auto-fix the issues found?", "n")
353
- self.linting.lint_changed(fix=fix)
354
- elif option == 8 and is_dbt2:
350
+ elif option == 5 and is_dbt2:
355
351
  name = get_input_string(
356
352
  "Enter model name or file path to format, or leave blank for the whole project "
357
353
  "('0' to cancel): ",
@@ -1,7 +1,7 @@
1
1
  from collections import defaultdict
2
2
 
3
3
  from datasecops_cli.services.git_service import GitService
4
- from datasecops_cli.models.project_config import SourceControl, WorkItems
4
+ from datasecops_cli.models.project_config import SourceControl, WorkItems, SOURCE_CONTROL_BRANCH_DEFAULTS
5
5
  from datasecops_cli.utilities.display import (
6
6
  clear, section_header, display_action_header, menu_option,
7
7
  get_input_number, get_input_string, get_input_true_false,
@@ -20,6 +20,18 @@ class GitOperationsMenu:
20
20
  self.deployment_branches = deployment_branches
21
21
  self.profile_name = profile_name
22
22
 
23
+ def _reserved_branch_names(self) -> set[str]:
24
+ """Branch names that should never be offered as deploy/reset targets: the
25
+ configured trunk/integration/production branches, plus their legacy defaults
26
+ (main/test/prod) — kept excluded even when a project configures different names,
27
+ since deployment_branches/environments may still carry the old literal names."""
28
+ return {
29
+ self.source_control.trunk_branch.lower(),
30
+ self.source_control.integration_branch.lower(),
31
+ self.source_control.production_branch.lower(),
32
+ *(v.lower() for v in SOURCE_CONTROL_BRANCH_DEFAULTS.values()),
33
+ }
34
+
23
35
  def show(self) -> None:
24
36
  self._menu()
25
37
  option = get_input_number("Choose an option: ")
@@ -49,21 +61,25 @@ class GitOperationsMenu:
49
61
 
50
62
  def _menu(self) -> None:
51
63
  clear()
64
+ trunk = self.source_control.trunk_branch
65
+ integration = self.source_control.integration_branch
66
+ production = self.source_control.production_branch
52
67
  section_header("Git Operations", self.profile_name, self.git.get_current_branch())
53
68
  menu_option(1, "branching - Manage branches")
54
69
  menu_option(2, "commit - Commit changes")
55
70
  menu_option(3, "push - Push to remote")
56
71
  menu_option(4, "pull - Pull from remote")
57
- menu_option(5, "rebase - Rebase with main")
72
+ menu_option(5, f"rebase - Rebase with {trunk}")
58
73
  menu_option(6, "deploy - Deploy to environment")
59
- menu_option(7, "squash to test - Squash merge into test")
60
- menu_option(8, "remove from test - Remove a branch from test")
61
- menu_option(9, "deploy to prod - Deploy main to production")
62
- menu_option(10, "reset branch - Force reset a branch from main")
74
+ menu_option(7, f"squash to test - Squash merge into {integration}")
75
+ menu_option(8, f"remove from test - Remove a branch from {integration}")
76
+ menu_option(9, f"deploy to prod - Deploy {trunk} to {production}")
77
+ menu_option(10, f"reset branch - Force reset a branch from {trunk}")
63
78
  menu_option(0, "back - Return to main menu")
64
79
 
65
80
  def _branch_menu(self) -> None:
66
81
  clear()
82
+ trunk = self.source_control.trunk_branch
67
83
  display_action_header("Branch Management")
68
84
  menu_option(1, "new - Create new branch")
69
85
  menu_option(2, "checkout - Checkout remote branch")
@@ -71,7 +87,7 @@ class GitOperationsMenu:
71
87
  menu_option(4, "delete - Delete local branch")
72
88
  menu_option(5, "prune - Prune remote branches")
73
89
  menu_option(6, "cleanup - Delete local branches & prune remote")
74
- menu_option(7, "reset - Reset to main")
90
+ menu_option(7, f"reset - Reset to {trunk}")
75
91
  menu_option(0, "back - Return to git menu")
76
92
  option = get_input_number("Choose an option: ")
77
93
  if option == 1:
@@ -170,7 +186,7 @@ class GitOperationsMenu:
170
186
  def _rebase_menu(self) -> None:
171
187
  clear()
172
188
  display_action_header("Rebase Options")
173
- menu_option(1, "rebase - Standard rebase with main")
189
+ menu_option(1, f"rebase - Standard rebase with {self.source_control.trunk_branch}")
174
190
  menu_option(2, "squash & rebase - Squash commits then rebase")
175
191
  menu_option(3, "squash - Squash all commits into one")
176
192
  menu_option(4, "continue - Continue after resolving conflicts")
@@ -193,7 +209,7 @@ class GitOperationsMenu:
193
209
  display_action_header("Deploy to Environment")
194
210
 
195
211
  # Build environment list from framework config, filtering non-deployable environments
196
- excluded = {"unit-test", "ci", "local-dev", "prod", "test", "main"}
212
+ excluded = {"unit-test", "ci", "local-dev", *self._reserved_branch_names()}
197
213
  environments = {}
198
214
  if self.source_control.environments:
199
215
  for env in self.source_control.environments:
@@ -225,42 +241,45 @@ class GitOperationsMenu:
225
241
  def _deploy_prod(self) -> None:
226
242
  display_action_header("Deploy to Production")
227
243
  current = self.git.get_current_branch()
228
- if current.lower() != "main":
229
- warning_line("Production deployments must come from the main branch")
230
- if get_input_true_false("Switch to main and deploy?", "n"):
231
- self.git.checkout_branch("main")
244
+ if current.lower() != self.source_control.trunk_branch.lower():
245
+ warning_line(f"Production deployments must come from the {self.source_control.trunk_branch} branch")
246
+ if get_input_true_false(f"Switch to {self.source_control.trunk_branch} and deploy?", "n"):
247
+ self.git.checkout_branch(self.source_control.trunk_branch)
232
248
  self.git.pull_branch()
233
249
  else:
234
250
  complete_action()
235
251
  return
236
- info_line("This will push main to prod (no force-push)")
252
+ info_line(f"This will push {self.source_control.trunk_branch} to {self.source_control.production_branch} (no force-push)")
237
253
  if get_input_true_false("Continue?", "n"):
238
- self.git.push_branch_to_destination("prod", force=False)
254
+ self.git.push_branch_to_destination(self.source_control.production_branch, force=False)
239
255
  complete_action()
240
256
 
241
257
  def _squash_merge_test(self) -> None:
242
- display_action_header("Squash Merge into Test")
258
+ display_action_header(f"Squash Merge into {self.source_control.integration_branch}")
243
259
  current = self.git.get_current_branch()
244
- info_line(f"This will squash merge {current} into the test branch")
260
+ info_line(f"This will squash merge {current} into the {self.source_control.integration_branch} branch")
245
261
 
246
- # Check current branch is up to date with main
262
+ # Check current branch is up to date with the trunk
247
263
  if not self.git.is_branch_up_to_date_with_main():
248
- error_line("Your branch is not up to date with main. Rebase with main first.")
264
+ error_line(
265
+ f"Your branch is not up to date with {self.source_control.trunk_branch}. "
266
+ f"Rebase with {self.source_control.trunk_branch} first."
267
+ )
249
268
  complete_action()
250
269
  return
251
270
 
252
- # Check for file overlaps with other branches on test
271
+ # Check for file overlaps with other branches on the integration branch
253
272
  conflicts = self.git.get_test_file_conflicts()
254
273
  if conflicts:
255
274
  # If conflicting branch still exists, reject
256
275
  active_conflicts = [c for c in conflicts if c["branch_exists"]]
257
276
  if active_conflicts:
258
- error_line("Cannot merge: files overlap with active branches on test:")
277
+ error_line(f"Cannot merge: files overlap with active branches on {self.source_control.integration_branch}:")
259
278
  for c in active_conflicts:
260
279
  warning_line(f" {c['branch']}:")
261
280
  for f in c["files"]:
262
281
  info_line(f" - {f}")
263
- error_line("Resolve with the branch owner or remove that branch from test first.")
282
+ error_line(f"Resolve with the branch owner or remove that branch from {self.source_control.integration_branch} first.")
264
283
  complete_action()
265
284
  return
266
285
 
@@ -268,7 +287,7 @@ class GitOperationsMenu:
268
287
  stale_conflicts = [c for c in conflicts if not c["branch_exists"]]
269
288
  if stale_conflicts:
270
289
  for c in stale_conflicts:
271
- warning_line(f"Removing stale branch {c['branch']} from test (branch no longer exists)")
290
+ warning_line(f"Removing stale branch {c['branch']} from {self.source_control.integration_branch} (branch no longer exists)")
272
291
  self.git.revert_from_test(c["sha"], c["branch"])
273
292
 
274
293
  if get_input_true_false("Continue?", "n"):
@@ -276,14 +295,14 @@ class GitOperationsMenu:
276
295
  complete_action()
277
296
 
278
297
  def _cherry_pick_test(self) -> None:
279
- display_action_header("Remove Branch from Test")
298
+ display_action_header(f"Remove Branch from {self.source_control.integration_branch}")
280
299
  commits = self.git.get_test_commits()
281
300
  if not commits:
282
- info_line("No branch merges found on test branch")
301
+ info_line(f"No branch merges found on {self.source_control.integration_branch} branch")
283
302
  complete_action()
284
303
  return
285
304
 
286
- info_line("Branches currently on test:")
305
+ info_line(f"Branches currently on {self.source_control.integration_branch}:")
287
306
  for i, c in enumerate(commits):
288
307
  info_line(f" [{i+1}] {c['branch']} ({c['sha'][:8]})")
289
308
 
@@ -294,10 +313,17 @@ class GitOperationsMenu:
294
313
  complete_action()
295
314
 
296
315
  def _reset_branch_from_main(self) -> None:
297
- display_action_header("Reset Branch from Main")
298
-
299
- # Build list of resettable branches from environments + deployment_branches
300
- excluded = {"main", "prod"}
316
+ display_action_header(f"Reset Branch from {self.source_control.trunk_branch}")
317
+
318
+ # Build list of resettable branches from environments + deployment_branches.
319
+ # Excludes the trunk/production roles (configured name + legacy default), since
320
+ # resetting either of those from itself is meaningless/unsafe.
321
+ excluded = {
322
+ self.source_control.trunk_branch.lower(),
323
+ self.source_control.production_branch.lower(),
324
+ SOURCE_CONTROL_BRANCH_DEFAULTS["trunk_branch"],
325
+ SOURCE_CONTROL_BRANCH_DEFAULTS["production_branch"],
326
+ }
301
327
  branches = {}
302
328
  if self.source_control.environments:
303
329
  for env in self.source_control.environments:
@@ -310,9 +336,10 @@ class GitOperationsMenu:
310
336
  if k.lower() not in excluded
311
337
  }
312
338
 
313
- # Always include test if not already present
314
- if "test" not in branches:
315
- branches["test"] = "test"
339
+ # Always include the integration branch if not already present
340
+ integration_branch = self.source_control.integration_branch
341
+ if integration_branch and integration_branch not in branches:
342
+ branches[integration_branch] = integration_branch
316
343
 
317
344
  if not branches:
318
345
  error_line("No branches available to reset")
@@ -323,7 +350,7 @@ class GitOperationsMenu:
323
350
  if selected == "back":
324
351
  return
325
352
 
326
- warning_line(f"This will FORCE RESET '{selected}' to match origin/main")
353
+ warning_line(f"This will FORCE RESET '{selected}' to match {self.source_control.trunk_branch}")
327
354
  warning_line("All existing commits on that branch will be lost")
328
355
  if get_input_true_false("Are you sure?", "n"):
329
356
  self.git.reset_branch_from_main(selected)