Skip to content

feat(commithelper-go): add extends support for remote config inheritance#83

Merged
kyungmi merged 4 commits into
mainfrom
feat/commithelper-go-extends
Jul 3, 2026
Merged

feat(commithelper-go): add extends support for remote config inheritance#83
kyungmi merged 4 commits into
mainfrom
feat/commithelper-go-extends

Conversation

@kyungmi

@kyungmi kyungmi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds extends support to @naverpay/commithelper-go, closing the feature gap with the Node.js version (@naverpay/commit-helper).

Closes #82

Motivation

Teams with multiple repositories want to maintain a single shared .commithelperrc.json (branch-prefix rules, protect lists, Jira passthrough) in a central place and override only project-specific rules locally.

Before:

// each repo must duplicate all shared rules
{
    "protect": ["main"],
    "rules": {
        "plan": "org/plan",
        "security": "Security/Security",
        "paymoney-plan": "Product-Planning/Paymoney_Plan"
        // ... 20+ more repeated across every repo
    }
}

After (remote URL):

{
    "extends": "https://raw.githubusercontent.com/my-org/.github/main/.commithelperrc.json",
    "rules": {
        "my-feature": "my-org/my-repo"
    }
}

After (local file path — for private registries):

{
    "extends": "./node_modules/@my-org/commithelperrc/.commithelperrc.json",
    "rules": {
        "my-feature": "my-org/my-repo"
    }
}

Install a shared config package as a dev dependency and reference it via local path. Works offline, versioned through package.json, no auth required — useful when your config is hosted on a private registry.

Changes

main.go

  • Config struct: add Extends *string json:"extends,omitempty"``
  • loadExtendsConfig(extends string) (Config, error): dispatches to HTTP fetch or local file read
  • fetchExtendsConfig(url string) (Config, error): fetches a remote config via HTTP/HTTPS
    • 10-second timeout via http.Client
    • Non-200 responses and invalid JSON are fatal errors
  • readLocalConfig(filePath string) (Config, error): reads a local file path
    • Relative paths resolved from current working directory (repo root)
  • mergeConfigs(base, local Config) Config: merge strategy
    • rules: base is the default; local overrides on key conflict
    • protect: union of base + local (deduped, base order preserved)
    • passthrough: union of base + local (deduped, base order preserved)
    • template: local wins; falls back to base if local is unset
  • loadConfig(): apply extends after local parse; nested extends are not followed

schema.json

  • Add extends property (URL or local file path, no pattern restriction)

main_test.go

  • TestMergeConfigs_Rules/Protect/Passthrough/Template
  • TestFetchExtendsConfig — valid fetch, 404, invalid JSON, nested extends not followed
  • TestReadLocalConfig — valid file, missing file, invalid JSON
  • TestLoadExtendsConfig — http dispatches to fetch, local path dispatches to read
  • TestProcessMessage_WithExtends — end-to-end with merged config

Merge strategy

Field Strategy
rules base is default; local key wins on conflict
protect union (base ∪ local), deduped
passthrough union (base ∪ local), deduped
template local wins; fall back to base
extends base config's own extends is ignored (no recursive loading)

- Add Extends field to Config struct
- Add fetchExtendsConfig: fetches and parses a remote .commithelperrc.json
  via HTTP/HTTPS (10s timeout, non-http URLs rejected)
- Add mergeConfigs: base (remote) + local merge strategy
  - rules: base is default, local overrides on key conflict
  - protect: union of base + local (deduped)
  - passthrough: union of base + local (deduped)
  - template: local wins, falls back to base
- Update loadConfig to apply extends after local parse
- Add extends property to schema.json
- Add tests: TestMergeConfigs_*, TestFetchExtendsConfig,
  TestProcessMessage_WithExtends (using net/http/httptest)

Closes #82
@kyungmi kyungmi requested a review from a team as a code owner July 3, 2026 03:18
@npayfebot

npayfebot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

✅ Changeset detected

Latest commit: 79f0831

@naverpay/commithelper-go package have detected changes.

If no version change is needed, please add skip-detect-change to the label.

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@naverpay/commithelper-go ✨ Minor
@naverpay/commithelper-go-darwin-arm64 ✨ Minor
@naverpay/commithelper-go-darwin-x64 ✨ Minor
@naverpay/commithelper-go-linux-x64 ✨ Minor
@naverpay/commithelper-go-win32-x64 ✨ Minor
powered by: naverpay changeset detect-add actions

kyungmi and others added 2 commits July 3, 2026 12:37
@kyungmi

kyungmi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

/canary-publish

@npayfebot

Copy link
Copy Markdown
Contributor

Published Canary Packages

@naverpay/commithelper-go@1.5.0-canary.260703-d9e0a03
@naverpay/commithelper-go-darwin-arm64@1.5.0-canary.260703-d9e0a03
@naverpay/commithelper-go-darwin-x64@1.5.0-canary.260703-d9e0a03
@naverpay/commithelper-go-linux-x64@1.5.0-canary.260703-d9e0a03
@naverpay/commithelper-go-win32-x64@1.5.0-canary.260703-d9e0a03

@kyungmi kyungmi self-assigned this Jul 3, 2026
@kyungmi kyungmi force-pushed the feat/commithelper-go-extends branch from dbc93b8 to 79f0831 Compare July 3, 2026 04:13
@kyungmi

kyungmi commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

/canary-publish

@npayfebot

Copy link
Copy Markdown
Contributor

Published Canary Packages

@naverpay/commithelper-go@1.5.0-canary.260703-79f0831
@naverpay/commithelper-go-darwin-arm64@1.5.0-canary.260703-79f0831
@naverpay/commithelper-go-darwin-x64@1.5.0-canary.260703-79f0831
@naverpay/commithelper-go-linux-x64@1.5.0-canary.260703-79f0831
@naverpay/commithelper-go-win32-x64@1.5.0-canary.260703-79f0831

@arale-dev arale-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

작업 감사합니다!

@djk01281 djk01281 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

감사합니다 !!

@kyungmi kyungmi merged commit 3aba993 into main Jul 3, 2026
7 checks passed
@kyungmi kyungmi deleted the feat/commithelper-go-extends branch July 3, 2026 04:55
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.

feat: support local file path in extends (both commit-helper and commithelper-go)

4 participants