Skip to content
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

Ensure that cluster catalog is initialized with branch master #915

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

simu
Copy link
Member

@simu simu commented Feb 9, 2024

Until now, Commodore could fail to push the initial catalog for a cluster if the user's Git config sets init.defaultBranch. The
observed error is:

 > Commiting changes...
 > Pushing catalog to remote...
Error: Failed to push to the catalog repository: Git exited with status code 1
The error reported was:
  stderr: 'error: src refspec master does not match any
error: failed to push some refs to 'ssh://<catalog repo>''

This error is caused because GitPython falls back to init.defaultBranch when creating the catalog repo unless initial_branch is specified.

However, since Commodore unconditionally falls back to trying to push master when no default branch can be identified in the remote repo (e.g. empty catalog repo), the push then fails because we're trying to push branch master which doesn't exist locally.

This isn't an issue for commodore component new and commodore package new since we explicitly fall back to creating a master branch when initializing the worktree for the new dependency.

Checklist

  • Keep pull requests small so they can be easily reviewed.
  • Update tests.
  • Categorize the PR by setting a good title and adding one of the labels:
    bug, enhancement, documentation, change, breaking, dependency, internal
    as they show up in the changelog

@simu simu added the bug Something isn't working label Feb 9, 2024
@simu simu requested a review from a team as a code owner February 9, 2024 10:15
@simu simu changed the title Fix/catalog init Ensure that cluster catalog is initialized with branch master Feb 9, 2024
@simu simu requested a review from a team February 9, 2024 10:16
@simu simu force-pushed the fix/catalog-init branch from 5f46e7e to ff125ab Compare February 9, 2024 10:17
simu added 2 commits February 9, 2024 11:21
Before this commit, Commodore could fail to push the initial catalog for
a cluster if the user's Git config sets `init.defaultBranch`. The
observed error is:

```
 > Commiting changes...
 > Pushing catalog to remote...
Error: Failed to push to the catalog repository: Git exited with status code 1
The error reported was:
  stderr: 'error: src refspec master does not match any
error: failed to push some refs to 'ssh://<catalog repo>''
```

This error is caused because GitPython falls back to `init.defaultBranch`
when creating the catalog repo unless `initial_branch` is specified.

However, since Commodore unconditionally falls back to trying to push
`master` when no default branch can be identified in the remote repo
(e.g. empty catalog repo), the push then fails because we're trying to
push branch `master` which doesn't exist locally.

This isn't an issue for `commodore component new` and `commodore package
new` since we explicitly fall back to creating a `master` branch when
initializing the worktree for the new dependency.
We also add a fixture which creates a predictable empty gitconfig for
the tests.
@simu simu force-pushed the fix/catalog-init branch from ff125ab to 26c9023 Compare February 9, 2024 10:21
@simu
Copy link
Member Author

simu commented Feb 9, 2024

Follow-up to rethink the handling of the default branch name in Commodore: #916

@simu simu merged commit 9c743fb into master Feb 9, 2024
23 checks passed
@simu simu deleted the fix/catalog-init branch February 9, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants