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
chore: Simplified GetRepoHTTPClient function #9396
Conversation
Signed-off-by: ls0f <lovedboy.tk@qq.com>
Codecov Report
@@ Coverage Diff @@
## master #9396 +/- ##
==========================================
+ Coverage 45.77% 45.79% +0.01%
==========================================
Files 220 220
Lines 26168 26159 -9
==========================================
Hits 11979 11979
+ Misses 12531 12524 -7
+ Partials 1658 1656 -2
Continue to review full report at Codecov.
|
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.
Nice optimization! Added a couple nitpicks.
Signed-off-by: ls0f <lovedboy.tk@qq.com>
@crenshaw-dev is there any progress please? |
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.
lgtm, thanks!
* chore: Simplified GetRepoHTTPClient function Signed-off-by: ls0f <lovedboy.tk@qq.com> * simplified code and improve unit test coverage Signed-off-by: ls0f <lovedboy.tk@qq.com> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com>
* git: prune any deleted refers before fetching This commit modifies `nativeGitClient.Fetch()` to call `git remote prune origin` before fetching refs. In some cases, an old branch may exist that conflicts with the name of a new branch. The old branch will have been deleted from `origin` but still exist locally in the `argocd-repo-server`. Example: an old branch `feature/foo` conflicts with a new branch `feature/foo/bar` In these cases, syncing an application results in the error: ``` rpc error: code = Internal desc = Failed to fetch default: `git fetch origin --tags --force` failed exit status 1: error: cannot lock ref 'refs/remotes/origin/feature/foo/bar': 'refs/remotes/origin/feature/foo' exists; cannot create 'refs/remotes/origin/feature/foo/bar' From https://github.com/org/repo ! [new branch] feature/foo/bar -> origin/feature/foo/bar (unable to update local ref) error: some local refs could not be updated; try running 'git remote prune origin' to remove any old, conflicting branches ``` Adding `git remote prune origin` before fetching, as recommended by the error message, should fix this issue. The current workaround is to restart the `argocd-repo-server` which should flush the local repository folder. This works when Argo CD is installed using the Helm chart. Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * fix: added extra protection to syncing app with replace (#9187) * fix: added extra protection to syncing app with replace Signed-off-by: ciiay <yicai@redhat.com> * Code clean up Signed-off-by: ciiay <yicai@redhat.com> * Updated logic for isAppOfAppsPattern Signed-off-by: ciiay <yicai@redhat.com> * Updated text strings as per comment Signed-off-by: ciiay <yicai@redhat.com> * Fixed lint issue Signed-off-by: ciiay <yicai@redhat.com> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * chore: Simplified GetRepoHTTPClient function (#9396) * chore: Simplified GetRepoHTTPClient function Signed-off-by: ls0f <lovedboy.tk@qq.com> * simplified code and improve unit test coverage Signed-off-by: ls0f <lovedboy.tk@qq.com> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * Only prune if fetch error message indicates that it is worthwhile, add unit tests Confirmed that `Test_nativeGitClient_Fetch_Prune` fails without the bug fix, succeeds with it. Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * fix: avoid k8s call before authorization for terminal endpoint (#9434) * fix: avoid k8s API call before authorization in k8s endpoint Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * check for bad project Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * lint Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * more logging Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * handle 404, return 500 instead of 400 for other errors Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * use user input Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * refactor validation Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * fix tests Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * fixes, tests Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * Match against "try running 'git remote prune origin'" Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> Co-authored-by: Yi Cai <yicai@redhat.com> Co-authored-by: ls0f <lovedboy.tk@qq.com> Co-authored-by: Michael Crenshaw <michael@crenshaw.dev>
* git: prune any deleted refers before fetching This commit modifies `nativeGitClient.Fetch()` to call `git remote prune origin` before fetching refs. In some cases, an old branch may exist that conflicts with the name of a new branch. The old branch will have been deleted from `origin` but still exist locally in the `argocd-repo-server`. Example: an old branch `feature/foo` conflicts with a new branch `feature/foo/bar` In these cases, syncing an application results in the error: ``` rpc error: code = Internal desc = Failed to fetch default: `git fetch origin --tags --force` failed exit status 1: error: cannot lock ref 'refs/remotes/origin/feature/foo/bar': 'refs/remotes/origin/feature/foo' exists; cannot create 'refs/remotes/origin/feature/foo/bar' From https://github.com/org/repo ! [new branch] feature/foo/bar -> origin/feature/foo/bar (unable to update local ref) error: some local refs could not be updated; try running 'git remote prune origin' to remove any old, conflicting branches ``` Adding `git remote prune origin` before fetching, as recommended by the error message, should fix this issue. The current workaround is to restart the `argocd-repo-server` which should flush the local repository folder. This works when Argo CD is installed using the Helm chart. Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * fix: added extra protection to syncing app with replace (#9187) * fix: added extra protection to syncing app with replace Signed-off-by: ciiay <yicai@redhat.com> * Code clean up Signed-off-by: ciiay <yicai@redhat.com> * Updated logic for isAppOfAppsPattern Signed-off-by: ciiay <yicai@redhat.com> * Updated text strings as per comment Signed-off-by: ciiay <yicai@redhat.com> * Fixed lint issue Signed-off-by: ciiay <yicai@redhat.com> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * chore: Simplified GetRepoHTTPClient function (#9396) * chore: Simplified GetRepoHTTPClient function Signed-off-by: ls0f <lovedboy.tk@qq.com> * simplified code and improve unit test coverage Signed-off-by: ls0f <lovedboy.tk@qq.com> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * Only prune if fetch error message indicates that it is worthwhile, add unit tests Confirmed that `Test_nativeGitClient_Fetch_Prune` fails without the bug fix, succeeds with it. Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * fix: avoid k8s call before authorization for terminal endpoint (#9434) * fix: avoid k8s API call before authorization in k8s endpoint Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * check for bad project Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * lint Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * more logging Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * handle 404, return 500 instead of 400 for other errors Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * use user input Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * refactor validation Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * fix tests Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> * fixes, tests Signed-off-by: Michael Crenshaw <michael@crenshaw.dev> Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> * Match against "try running 'git remote prune origin'" Signed-off-by: Kevin Snyder <kevin.snyder.codes@gmail.com> Co-authored-by: Yi Cai <yicai@redhat.com> Co-authored-by: ls0f <lovedboy.tk@qq.com> Co-authored-by: Michael Crenshaw <michael@crenshaw.dev> Signed-off-by: Michael Crenshaw <michael@crenshaw.dev>
Signed-off-by: ls0f lovedboy.tk@qq.com
Note on DCO:
If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.
Checklist: