-
Notifications
You must be signed in to change notification settings - Fork 176
Feature: Default branch and path flags intelligently. #3371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Default branch and path flags intelligently. #3371
Conversation
60e2c3d to
c6484ce
Compare
Codecov Report❌ Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7c48052 to
c1ff8fa
Compare
|
/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. |
gauron99
left a comment
There was a problem hiding this 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
gauron99
left a comment
There was a problem hiding this 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
lkingland
left a comment
There was a problem hiding this 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.
cmd/common/common.go
Outdated
| if _, err := os.Stat(path); err != nil { | ||
| return "", err | ||
| } | ||
|
|
||
| return g.execGitCmdWith("-C", path, "symbolic-ref", "--short", "HEAD") |
There was a problem hiding this comment.
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, nilThere was a problem hiding this comment.
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 😸 👍
fc0bf27 to
f0cad73
Compare
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>
877551b to
08b45f5
Compare
|
/lgtm |
|
/approve |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold |
|
/unhold |
Changes
--pathflag to current working directory when empty or "."--branchflag to current git branch instead of hardcoded "main"getCurrentGitBranchfromcmd/deploy.gointo sharedgitCliWrappercmd/config_ci_int_test.go, unit tests use stubs/kind enhancement
Relates to #3256
Release Note
Docs