Skip to content

Support bare repo creation #9905

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

Merged
merged 9 commits into from
Nov 15, 2024
Merged

Conversation

williammartin
Copy link
Member

Description

Fixes #9904

Acceptance Criteria

Given My cwd is a bare git repository
When I run gh repo create, and I choose the option to push it to GitHub
Then It succeeds in creating and pushing the repo, mirroring all refs

➜  cli-triaging git:(main) ✗ cd non-bare

➜  non-bare git:(feature) git branch | cat
* feature
  main

➜  non-bare git:(feature) cd ..

➜  cli-triaging git:(main) ✗ git clone --bare non-bare bare
Cloning into bare repository 'bare'...
done.

➜  cli-triaging git:(main) ✗ cd bare

➜  bare git:(feature) ~/workspace/cli/bin/gh repo create
? What would you like to do? Push an existing local repository to GitHub
? Path to local repository .
? Repository name bare
? Repository owner williammartin-test-org
? Description
? Visibility Private
✓ Created repository williammartin-test-org/bare on GitHub
  https://github.com/williammartin-test-org/bare
? Add a remote? Yes
? What should the new remote be called? bare
✓ Added remote https://github.com/williammartin-test-org/bare.git
? Would you like to mirror all refs to "bare"? Yes
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 10 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 242 bytes | 242.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/williammartin-test-org/bare.git
 * [new branch]      feature -> feature
 * [new branch]      main -> main
✓ Mirrored all refs to https://github.com/williammartin-test-org/bare.git

➜  bare git:(feature) gh api /repos/williammartin-test-org/bare/branches | cat
[{"name":"feature","commit":{"sha":"fca77ed5e5be49ff42779f98061bcd0453f9649e","url":"https://api.github.com/repos/williammartin-test-org/bare/commits/fca77ed5e5be49ff42779f98061bcd0453f9649e"},"protected":false},{"name":"main","commit":{"sha":"fcf697da1ed589b88124193e59ca6ba3243a243c","url":"https://api.github.com/repos/williammartin-test-org/bare/commits/fcf697da1ed589b88124193e59ca6ba3243a243c"},"protected":false}]%

Given My cwd is a bare git repository
When I run gh repo create --source . --push --private
Then It succeeds in creating and pushing the repo, mirroring all refs

➜  cli-triaging git:(main) ✗ cd non-bare

➜  non-bare git:(feature) git branch | cat
* feature
  main

➜  non-bare git:(feature) cd ..

➜  cli-triaging git:(main) ✗ git clone --bare non-bare bare
Cloning into bare repository 'bare'...
done.

➜  bare git:(feature) ~/workspace/cli/bin/gh repo create williammartin-test-org/bare --source . --push --private --remote bare
✓ Created repository williammartin-test-org/bare on GitHub
  https://github.com/williammartin-test-org/bare
✓ Added remote https://github.com/williammartin-test-org/bare.git
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 10 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 242 bytes | 242.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (1/1), done.
To https://github.com/williammartin-test-org/bare.git
 * [new branch]      feature -> feature
 * [new branch]      main -> main
✓ Mirrored all refs to https://github.com/williammartin-test-org/bare.git

➜  bare git:(feature) gh api /repos/williammartin-test-org/bare/branches | cat
[{"name":"feature","commit":{"sha":"fca77ed5e5be49ff42779f98061bcd0453f9649e","url":"https://api.github.com/repos/williammartin-test-org/bare/commits/fca77ed5e5be49ff42779f98061bcd0453f9649e"},"protected":false},{"name":"main","commit":{"sha":"fcf697da1ed589b88124193e59ca6ba3243a243c","url":"https://api.github.com/repos/williammartin-test-org/bare/commits/fcf697da1ed589b88124193e59ca6ba3243a243c"},"protected":false}]%

Acceptance Test

I also created an Acceptance Test:

➜ set -o pipefail | GH_ACCEPTANCE_SCRIPT=repo-create-bare.txtar GH_ACCEPTANCE_HOST=github.com GH_ACCEPTANCE_ORG=gh-acceptance-testing go test -tags acceptance -run '^TestRepo' -json github.com/cli/cli/v2/acceptance | tparse --all go test
┌───────────────────────────────────────────────────────────────────────────────────┐
│  STATUS │ ELAPSED │           TEST            │             PACKAGE               │
│─────────┼─────────┼───────────────────────────┼───────────────────────────────────│
│  PASS   │    4.23 │ TestRepo/repo-create-bare │ github.com/cli/cli/v2/acceptance  │
│  PASS   │    0.00 │ TestRepo                  │ github.com/cli/cli/v2/acceptance  │
└───────────────────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────────────────────────────────────┐
│  STATUS │ ELAPSED │             PACKAGE              │ COVER │ PASS │ FAIL │ SKIP  │
│─────────┼─────────┼──────────────────────────────────┼───────┼──────┼──────┼───────│
│  PASS   │  4.82s  │ github.com/cli/cli/v2/acceptance │  --   │  2   │  0   │  0    │
└────────────────────────────────────────────────────────────────────────────────────┘

Copy link
Member

@BagToad BagToad left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@BagToad BagToad enabled auto-merge November 15, 2024 19:01
@BagToad BagToad merged commit 9decf1b into trunk Nov 15, 2024
@BagToad BagToad deleted the 9904-gh-repo-create-to-work-on-bare-repos branch November 15, 2024 19:08
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Nov 28, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [cli/cli](https://github.com/cli/cli) | minor | `v2.62.0` -> `v2.63.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>cli/cli (cli/cli)</summary>

### [`v2.63.0`](https://github.com/cli/cli/releases/tag/v2.63.0): GitHub CLI 2.63.0

[Compare Source](cli/cli@v2.62.0...v2.63.0)

#### What's Changed

-   Support bare repo creation by [@&#8203;williammartin](https://github.com/williammartin) in cli/cli#9905
-   Refactor the `getAttestations` functions by [@&#8203;malancas](https://github.com/malancas) in cli/cli#9892
-   Added a section on manual verification of the relases. by [@&#8203;kommendorkapten](https://github.com/kommendorkapten) in cli/cli#9936
-   Adding option to return `baseRefOid` in `pr view` by [@&#8203;daliusd](https://github.com/daliusd) in cli/cli#9938
-   Update verification results printing by [@&#8203;malancas](https://github.com/malancas) in cli/cli#9937
-   Fix some multiline command documentation to use `heredoc` strings by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9948
-   Print friendly error when `release create` fails due to missing `workflow` OAuth scope by [@&#8203;BagToad](https://github.com/BagToad) in cli/cli#9791

**Full Changelog**: cli/cli@v2.62.0...v2.63.0

#### Security

-   A security vulnerability has been identified in the GitHub CLI that could leak authentication tokens when cloning repositories containing git submodules hosted outside of GitHub.com and ghe.com.

    For more information, see GHSA-jwcm-9g39-pmcw

#### New Contributors

-   [@&#8203;daliusd](https://github.com/daliusd) made their first contribution in cli/cli#9938

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
@DoDonFin4

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gh repo create to work on bare repos
3 participants