Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .claude/skills/bazel/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: bazel
description: Use when asking questions about Bazel builds, troubleshooting Bazel errors, adding BUILD files, understanding MODULE.bazel, running tests with Bazel, or any Bazel-related task in this project
---

# Bazel Quick Reference

Read `docs/bazel.md` for full documentation. Below is a quick reference.

## Commands

| Task | Command |
|------|---------|
| Build everything | `bazel build //...` |
| Build gh binary | `bazel build //cmd/gh` |
| Run all tests | `bazel test //...` |
| Run one test | `bazel test //git:git_test` |
| Regenerate BUILD files | `bazel run //:gazelle` |
| Update deps | `bazel run //:gazelle -- update-repos -from_file=go.mod` |
| Clean | `bazel clean` |
| Debug build | `bazel build //... --verbose_failures` |

## Common Fixes

- **"missing strict dependencies"** → `bazel run //:gazelle`
- **"no such package"** → add repo to `use_repo(go_deps, ...)` in MODULE.bazel
- **"flag provided but not defined"** → wrong Gazelle directive, check MODULE.bazel
- **Test file not found** → sandbox issue; copy fixtures to `t.TempDir()` at runtime

## Project Quirks

- `certificate-transparency-go` needs `gazelle:proto disable`
- Git tests use `cpFixture()` to work around sandbox restrictions
- Cross-compilation and install not yet configured; use `make` for those

## Labels

```
//cmd/gh # the gh binary
//git:git_test # test target
//... # all targets
```
15 changes: 1 addition & 14 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
version: 2
updates:
- package-ecosystem: gomod
directory: "/"
schedule:
interval: "daily"
ignore:
- dependency-name: "*"
update-types:
- version-update:semver-minor
- version-update:semver-major
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
updates: []
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,11 @@
*~

vendor/

# Bazel
/bazel-*
/bazel-bin
/bazel-out
/bazel-testlogs
/bazel-workspace
MODULE.bazel.lock
42 changes: 42 additions & 0 deletions .mimocode/skills/bazel/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: bazel
description: Use when asking questions about Bazel builds, troubleshooting Bazel errors, adding BUILD files, understanding MODULE.bazel, running tests with Bazel, or any Bazel-related task in this project
---

# Bazel Quick Reference

Read `docs/bazel.md` for full documentation. Below is a quick reference.

## Commands

| Task | Command |
|------|---------|
| Build everything | `bazel build //...` |
| Build gh binary | `bazel build //cmd/gh` |
| Run all tests | `bazel test //...` |
| Run one test | `bazel test //git:git_test` |
| Regenerate BUILD files | `bazel run //:gazelle` |
| Update deps | `bazel run //:gazelle -- update-repos -from_file=go.mod` |
| Clean | `bazel clean` |
| Debug build | `bazel build //... --verbose_failures` |

## Common Fixes

- **"missing strict dependencies"** → `bazel run //:gazelle`
- **"no such package"** → add repo to `use_repo(go_deps, ...)` in MODULE.bazel
- **"flag provided but not defined"** → wrong Gazelle directive, check MODULE.bazel
- **Test file not found** → sandbox issue; copy fixtures to `t.TempDir()` at runtime

## Project Quirks

- `certificate-transparency-go` needs `gazelle:proto disable`
- Git tests use `cpFixture()` to work around sandbox restrictions
- Cross-compilation and install not yet configured; use `make` for those

## Labels

```
//cmd/gh # the gh binary
//git:git_test # test target
//... # all targets
```
42 changes: 42 additions & 0 deletions .opencode/skills/bazel/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: bazel
description: Use when asking questions about Bazel builds, troubleshooting Bazel errors, adding BUILD files, understanding MODULE.bazel, running tests with Bazel, or any Bazel-related task in this project
---

# Bazel Quick Reference

Read `docs/bazel.md` for full documentation. Below is a quick reference.

## Commands

| Task | Command |
|------|---------|
| Build everything | `bazel build //...` |
| Build gh binary | `bazel build //cmd/gh` |
| Run all tests | `bazel test //...` |
| Run one test | `bazel test //git:git_test` |
| Regenerate BUILD files | `bazel run //:gazelle` |
| Update deps | `bazel run //:gazelle -- update-repos -from_file=go.mod` |
| Clean | `bazel clean` |
| Debug build | `bazel build //... --verbose_failures` |

## Common Fixes

- **"missing strict dependencies"** → `bazel run //:gazelle`
- **"no such package"** → add repo to `use_repo(go_deps, ...)` in MODULE.bazel
- **"flag provided but not defined"** → wrong Gazelle directive, check MODULE.bazel
- **Test file not found** → sandbox issue; copy fixtures to `t.TempDir()` at runtime

## Project Quirks

- `certificate-transparency-go` needs `gazelle:proto disable`
- Git tests use `cpFixture()` to work around sandbox restrictions
- Cross-compilation and install not yet configured; use `make` for those

## Labels

```
//cmd/gh # the gh binary
//git:git_test # test target
//... # all targets
```
48 changes: 48 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Agents Guide

## Bazel Build System

This project can be built with Bazel. The main config is `MODULE.bazel`. BUILD files are auto-generated by Gazelle from `go.mod`.

### Common Commands

```sh
bazel build //... # build everything
bazel build //cmd/gh # build the gh binary
bazel test //... # run all tests
bazel test //git:git_test # run a specific test
bazel run //:gazelle # regenerate BUILD files
bazel run //:gazelle -- update-repos -from_file=go.mod # update deps
```

### When Builds Fail

1. **"missing strict dependencies"** → run `bazel run //:gazelle` to regenerate BUILD files
2. **"no such package"** → add missing repo to `use_repo(go_deps, ...)` in MODULE.bazel
3. **"flag provided but not defined"** → wrong Gazelle directive name, check MODULE.bazel
4. **Test can't find files** → Bazel sandbox isolates tests; copy fixtures to `t.TempDir()` at runtime

### Adding Dependencies

```sh
go get github.com/new/dep@version
go mod tidy
bazel run //:gazelle -- update-repos -from_file=go.mod
```

### Project-Specific Notes

- Go SDK 1.24.4 is pinned in MODULE.bazel
- `certificate-transparency-go` needs `gazelle:proto disable` directive
- Git tests use `cpFixture()` helper to work around sandbox restrictions
- Cross-compilation and install targets not yet configured; use `make` for those

### Debugging

```sh
bazel build //... --verbose_failures # see failing commands
bazel build //... --sandbox_debug # debug sandbox issues
bazel query 'deps(//cmd/gh)' # check dependencies
```

Full documentation: `docs/bazel.md`
4 changes: 4 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
load("@gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/cli/cli/v2
gazelle(name = "gazelle")
76 changes: 76 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module(
name = "gh",
version = "2.0.0",
)

bazel_dep(name = "rules_go", version = "0.60.0")
bazel_dep(name = "gazelle", version = "0.45.0")
bazel_dep(name = "bazel_skylib", version = "1.8.2")
bazel_dep(name = "rules_cc", version = "0.2.17")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "protobuf", version = "33.4")
bazel_dep(name = "aspect_bazel_lib", version = "2.20.4")

go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.24.4")

go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
go_deps.gazelle_override(
path = "github.com/google/certificate-transparency-go",
build_file_generation = "auto",
directives = [
"gazelle:proto disable",
],
)
use_repo(
go_deps,
"com_github_alecaivazis_survey_v2",
"com_github_briandowns_spinner",
"com_github_cenkalti_backoff_v4",
"com_github_charmbracelet_glamour",
"com_github_charmbracelet_lipgloss",
"com_github_cli_go_gh_v2",
"com_github_cli_go_internal",
"com_github_cli_oauth",
"com_github_cli_safeexec",
"com_github_cpuguy83_go_md2man_v2",
"com_github_creack_pty",
"com_github_digitorus_timestamp",
"com_github_distribution_reference",
"com_github_gabriel_vasile_mimetype",
"com_github_gdamore_tcell_v2",
"com_github_google_go_cmp",
"com_github_google_go_containerregistry",
"com_github_google_shlex",
"com_github_gorilla_websocket",
"com_github_hashicorp_go_multierror",
"com_github_hashicorp_go_version",
"com_github_henvic_httpretty",
"com_github_in_toto_attestation",
"com_github_joho_godotenv",
"com_github_kballard_go_shellquote",
"com_github_makenowjust_heredoc",
"com_github_mattn_go_colorable",
"com_github_mattn_go_isatty",
"com_github_mgutz_ansi",
"com_github_microsoft_dev_tunnels",
"com_github_muhammadmuzzammil1998_jsonc",
"com_github_opentracing_opentracing_go",
"com_github_rivo_tview",
"com_github_shurcool_githubv4",
"com_github_sigstore_protobuf_specs",
"com_github_sigstore_sigstore_go",
"com_github_spf13_cobra",
"com_github_spf13_pflag",
"com_github_stretchr_testify",
"com_github_zalando_go_keyring",
"in_gopkg_h2non_gock_v1",
"in_gopkg_yaml_v3",
"org_golang_google_grpc",
"org_golang_google_protobuf",
"org_golang_x_crypto",
"org_golang_x_sync",
"org_golang_x_term",
"org_golang_x_text",
)
58 changes: 58 additions & 0 deletions api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "api",
srcs = [
"client.go",
"export_pr.go",
"export_repo.go",
"http_client.go",
"queries_branch_issue_reference.go",
"queries_comments.go",
"queries_issue.go",
"queries_org.go",
"queries_pr.go",
"queries_pr_review.go",
"queries_projects_v2.go",
"queries_repo.go",
"queries_user.go",
"query_builder.go",
"reaction_groups.go",
],
importpath = "github.com/cli/cli/v2/api",
visibility = ["//visibility:public"],
deps = [
"//internal/ghinstance",
"//internal/ghrepo",
"//pkg/set",
"//utils",
"@com_github_cli_go_gh_v2//pkg/api",
"@com_github_cli_go_gh_v2//pkg/auth",
"@com_github_shurcool_githubv4//:githubv4",
"@org_golang_x_sync//errgroup",
],
)

go_test(
name = "api_test",
srcs = [
"client_test.go",
"export_pr_test.go",
"http_client_test.go",
"pull_request_test.go",
"queries_pr_test.go",
"queries_projects_v2_test.go",
"queries_repo_test.go",
"query_builder_test.go",
"reaction_groups_test.go",
],
embed = [":api"],
deps = [
"//internal/ghrepo",
"//pkg/httpmock",
"//pkg/iostreams",
"@com_github_makenowjust_heredoc//:heredoc",
"@com_github_stretchr_testify//assert",
"@com_github_stretchr_testify//require",
],
)
31 changes: 31 additions & 0 deletions cmd/gen-docs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "gen-docs_lib",
srcs = ["main.go"],
importpath = "github.com/cli/cli/v2/cmd/gen-docs",
visibility = ["//visibility:private"],
deps = [
"//internal/config",
"//internal/docs",
"//internal/gh",
"//internal/ghrepo",
"//pkg/cmd/root",
"//pkg/cmdutil",
"//pkg/extensions",
"//pkg/iostreams",
"@com_github_spf13_pflag//:pflag",
],
)

go_binary(
name = "gen-docs",
embed = [":gen-docs_lib"],
visibility = ["//visibility:public"],
)

go_test(
name = "gen-docs_test",
srcs = ["main_test.go"],
embed = [":gen-docs_lib"],
)
15 changes: 15 additions & 0 deletions cmd/gh/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_go//go:def.bzl", "go_binary", "go_library")

go_library(
name = "gh_lib",
srcs = ["main.go"],
importpath = "github.com/cli/cli/v2/cmd/gh",
visibility = ["//visibility:private"],
deps = ["//internal/ghcmd"],
)

go_binary(
name = "gh",
embed = [":gh_lib"],
visibility = ["//visibility:public"],
)
Loading
Loading