Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git: prune any deleted refs before fetching (#9504)
* 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>
- Loading branch information