Skip to content

Conversation

@twoGiants
Copy link
Contributor

@twoGiants twoGiants commented Jan 19, 2026

Changes

  • 🎁 Default --path flag to current working directory when empty or "."
  • 🎁 Default --branch flag to current git branch instead of hardcoded "main"
  • 🧹 Consolidate duplicate getCurrentGitBranch from cmd/deploy.go into shared gitCliWrapper
  • 🧹 Reorganize tests: integration tests to cmd/config_ci_int_test.go, unit tests use stubs

/kind enhancement

Relates to #3256

Release Note

The `func config ci` command now resolves --path and --branch flags intelligently:
- --path defaults to current working directory when empty or "."
- --branch defaults to current git branch when not specified (previously "main")

Docs


@knative-prow knative-prow bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jan 19, 2026
@twoGiants twoGiants force-pushed the issue-778-default-branch-current-branch branch 2 times, most recently from 60e2c3d to c6484ce Compare January 19, 2026 09:44
@twoGiants twoGiants changed the title Feature: Default branch flag to current git branch. Feature: Default branch and path flags intelligently. Jan 19, 2026
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 74.46809% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.58%. Comparing base (f85f66d) to head (08b45f5).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
cmd/common/common.go 81.39% 8 Missing ⚠️
cmd/ci/config.go 66.66% 4 Missing and 2 partials ⚠️
cmd/testing/factory.go 0.00% 4 Missing ⚠️
cmd/ci/writer.go 60.00% 2 Missing ⚠️
pkg/knative/deployer.go 66.66% 1 Missing and 1 partial ⚠️
cmd/deploy.go 0.00% 1 Missing ⚠️
cmd/describe.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3371      +/-   ##
==========================================
- Coverage   55.72%   55.58%   -0.15%     
==========================================
  Files         170      173       +3     
  Lines       19963    20061      +98     
==========================================
+ Hits        11125    11151      +26     
- Misses       7728     7793      +65     
- Partials     1110     1117       +7     
Flag Coverage Δ
e2e 39.71% <25.97%> (-0.04%) ⬇️
e2e go 35.50% <16.88%> (+0.03%) ⬆️
e2e node 31.27% <16.88%> (+0.14%) ⬆️
e2e python 34.98% <16.88%> (-0.15%) ⬇️
e2e quarkus 31.39% <16.88%> (+0.12%) ⬆️
e2e rust 30.83% <16.88%> (+0.09%) ⬆️
e2e springboot ?
e2e typescript 31.38% <16.88%> (+0.14%) ⬆️
integration 18.60% <6.25%> (-0.03%) ⬇️
unit macos-14 44.88% <77.50%> (-0.23%) ⬇️
unit macos-latest 44.88% <77.50%> (-0.23%) ⬇️
unit ubuntu-24.04-arm 44.97% <74.46%> (-0.27%) ⬇️
unit ubuntu-latest 45.77% <77.50%> (-0.24%) ⬇️
unit windows-latest 44.90% <77.50%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@twoGiants twoGiants force-pushed the issue-778-default-branch-current-branch branch 3 times, most recently from 7c48052 to c1ff8fa Compare January 20, 2026 09:10
@twoGiants
Copy link
Contributor Author

/cc @gauron99 @matejvasek @lkingland

The PR is ready for review. It looks bigger than it is, because I separated the integration tests from the unit test in a file but there were no new integration tests added. I added just some fixes because they started to fail after I added the new logic.

Copy link
Contributor

@gauron99 gauron99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! few comments from me

@twoGiants twoGiants requested a review from gauron99 January 20, 2026 14:56
Copy link
Contributor

@gauron99 gauron99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! found one outdated comment reference otherwise all good from my side

Copy link
Member

@lkingland lkingland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean!

I especially like the comprehensive tests, and that the unit tests and integration tests are properly split based on the use of a real FS.

Just one small suggestion about helpful error messages when there's no git repo (see below).

Other than that, it's just the comment David mentioned, and a misbehaving integration test.

Comment on lines 105 to 109
if _, err := os.Stat(path); err != nil {
return "", err
}

return g.execGitCmdWith("-C", path, "symbolic-ref", "--short", "HEAD")
Copy link
Member

@lkingland lkingland Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correctly, we'll correctly get errors bubbled up when there's no git repo, but we might want to help out a bit when the user tries to use this without having their Function in source-control. Perhaps slightly more vebose error messaging would be enough?

    branch, err := g.execGitCmdWith("-C", path, "symbolic-ref", "--short", "HEAD")
    if err != nil {
            return "", fmt.Errorf("could not detect git branch for '%s'. "+
                    "Has git been initialized for this Function? %w", path, err)
    }
    return branch, nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, much better! Will update 😸 👍

@twoGiants twoGiants force-pushed the issue-778-default-branch-current-branch branch from fc0bf27 to f0cad73 Compare January 21, 2026 09:11
Previously, `func config ci` had no working --path flag and the --branch
flag had the "main" branch as default. Now both flags resolve to
sensible defaults:
- --path defaults to current working directory when empty or "."
- --branch defaults to current git branch when not specified

The implementation adds a gitCliWrapper in cmd/common that calls
`git symbolic-ref --short HEAD` to detect the current branch. This
also consolidates the duplicate getCurrentGitBranch function from
cmd/deploy.go into the shared wrapper.

Tests were reorganized: integration tests using real filesystem moved
to cmd/config_ci_int_test.go, while unit tests use stubs for faster
isolated testing. New tests cover gitCliWrapper, path resolution,
and branch resolution logic.

Issue knative#3256

Signed-off-by: Stanislav Jakuschevskij <sjakusch@redhat.com>
@twoGiants twoGiants force-pushed the issue-778-default-branch-current-branch branch from 877551b to 08b45f5 Compare January 21, 2026 10:15
@gauron99
Copy link
Contributor

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 21, 2026
@gauron99
Copy link
Contributor

/approve

@knative-prow
Copy link

knative-prow bot commented Jan 21, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauron99, twoGiants

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 21, 2026
@gauron99
Copy link
Contributor

/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2026
@gauron99
Copy link
Contributor

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2026
@knative-prow knative-prow bot merged commit 66d2f4c into knative:main Jan 21, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/enhancement lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants