You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8cae773
Browse filesBrowse the repository at this point in the historyBrowse files
Apply the explicit-ref check to the combined default-branch detection
With --scm github, the SCM adapter's is_default_branch was copied into
config.default_branch, so DEFAULT_BRANCH=true restored default-branch status
after git had rejected a mismatched --branch or --commit-sha.
resolve_default_branch() now makes the decision in one place:
--no-default-branch and --default-branch are authoritative, and otherwise the
SCM and git detection results are combined before the explicit-ref check runs.
Git.apply_explicit_ref() only records the named ref and switches the commit
details; explicit_ref_allows_default_branch() does the check.
Adds CLI-path tests with SCM detection enabled covering both outgoing flags,
the explicit overrides, and the commit message and committer fallback. Sets
the release to 2.16.0 and updates the CLI reference, README and CHANGELOG.
When a job scans a different ref than the one that triggered it, such as a release tag, pass `--branch` and `--commit-sha` for that ref. [Default Branch Detection](https://github.com/SocketDev/socket-python-cli/blob/main/docs/cli-reference.md#default-branch-detection) covers when to add `--no-default-branch`.
|`--default-branch`| False |*auto*| Make this branch the default branch (auto-detected from git and CI environment when not specified) |
327
-
|`--no-default-branch`| False | False |Never make this scan the default branch or its head scan, whatever git or the CI environment says. Mutually exclusive with `--default-branch`|
327
+
|`--no-default-branch`| False | False |Prevent the scan from changing the repository's default branch or updating a branch head, whatever git or the CI environment detects. Mutually exclusive with `--default-branch`. See [Default Branch Detection](#default-branch-detection) |
328
328
| `--include-module-folders` | False | False | Includes supported manifests found under `node_modules`, `bower_components`, and `jspm_packages` in manifest discovery. Equivalent to `--include-dirs node_modules,bower_components,jspm_packages`. Other discovery exclusions still apply. For an inventory of installed packages, see [Packages installed outside the lockfile](troubleshooting.md#packages-installed-outside-the-lockfile). |
329
329
330
330
#### Output Configuration
@@ -720,14 +720,32 @@ The CLI now automatically detects repository information from your git environme
720
720
> For *octopus merges* (three or more parents), Git only reports changes relative to the first parent. This can lead to incomplete or empty file lists if changes only exist relative to other parents. In these cases, differential scanning may be skipped. To ensure coverage, use `--ignore-commit-files` to compare regardless of the detected changes, or specify files explicitly with `--files`.
721
721
### Default Branch Detection
722
722
723
-
The CLI uses intelligent default branch detection with the following priority:
723
+
`--default-branch` always marks the scan as the repository's default branch. `--no-default-branch` never does, and the scan does not update a branch head. The two flags are mutually exclusive, on the command line and in a `--config` file.
724
724
725
-
1. **Explicit `--no-default-branch` or `--default-branch` flag**: Takes highest priority when specified
726
-
2. **CI environment detection**: Uses CI platform variables (GitHub Actions, GitLab CI, and Bitbucket Pipelines)
727
-
3. **Git repository analysis**: Compares current branch with repository's default branch
728
-
4. **Fallback**: Defaults to `false`if none of the above methods succeed
725
+
Without either flag, the CLI marks the scan when automatic detection finds the default branch: CI platform variables (GitHub Actions, GitLab CI, Bitbucket Pipelines and Buildkite), the `DEFAULT_BRANCH` variable with `--scm github`, or, outside CI, the local checkout. Otherwise the scan is not marked.
729
726
730
-
When `--branch` or `--commit-sha` names a different ref than the CI variables, git repository analysis also checks the ref you passed: the scan is not treated as the default branch unless that branch is the default branch and that commit is on it. These flags never turn detection on; use `--default-branch`forthat. With `--commit-sha`, the commit message and committer come from that commit when it isin the checkout.
727
+
#### Scanning a different ref than the CI run
728
+
729
+
When `--branch` or `--commit-sha` names a different ref than the CI variables, automatic detection also checks the ref you passed. The scan is marked only when that branch is the default branch and that commit is in the checkout and reachable from the default branch. These flags never turn detection on.
730
+
731
+
The commit check is reachability, so an older commit already in the default branch's history can still qualify: for example, a release tag that was merged back into the default branch, scanned with `--commit-sha` and no `--branch`. Pass `--no-default-branch` when a scan of such a ref must not change the default branch.
732
+
733
+
With `--commit-sha`, that commit supplies the commit message (unless `--commit-message` is set) and the git fallback for the committer, when the checkout has it. `--committers` and CI actor values (`GITHUB_ACTOR`, `GITLAB_USER_LOGIN`, `BITBUCKET_STEP_TRIGGERER_UUID`) still take precedence over the commit's committer.
734
+
735
+
Example: a GitHub Actions job that runs on `develop`, the default branch, after a release and scans the release tag on `main`:
736
+
737
+
```yaml
738
+
- uses: actions/checkout@v4
739
+
with:
740
+
ref: v1.2.0
741
+
fetch-depth: 0
742
+
- name: Scan the release tag
743
+
run: socketcli --target-path . --branch main --commit-sha "$(git rev-parse HEAD)"
`GITHUB_REF` and `GITHUB_SHA` describe `develop`, so without `--branch` and `--commit-sha` the scan would be marked as the default branch with `develop`'s commit message. With them, the scan is recorded on `main` with the tag's commit message and is not marked, because `main` is not the default branch. A job that passes only `--commit-sha` gets the reachability check alone; if the tag commit is also in `develop`'s history, that scan still qualifies, so add `--no-default-branch`.
731
749
732
750
A scan on the default branch also becomes that branch's head scan. `--pending-head` is deprecated and has no effect: it is still accepted so existing pipelines keep working, but it logs a warning. Use `--default-branch` instead.
0 commit comments