go-github
go-github copied to clipboard
docs: Clarify `CreateTree` semantics and `TreeEntry` usage
Summary
This PR improves the documentation for CreateTree and TreeEntry to clarify several behaviors that are not obvious from the existing docs:
-
Merge semantics: When
baseTreeis provided, entries are merged with that tree - paths not mentioned inentriesare preserved from the base tree - Duplicate entries: If the same path appears multiple times in entries, the last entry wins
-
File/directory deletion: To delete an entry, set both
SHAandContentto nil; this works for both files and entire directories -
Type/Mode ignored on delete: When deleting, the
TypeandModefields are ignored by the API; onlyPathis required -
Content vs SHA: Clarifies when to use
Content(small text files) vsSHA(reference to existing blob), with a reference toCreateBlobfor binary files
These behaviors were verified experimentally against the GitHub API.
Test plan
- [x] Documentation-only change, no code changes
- [x] Existing tests pass (
go test ./github/... -run TestGitService_.*Tree)
🤖 Generated with Claude Code
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 92.48%. Comparing base (59f33d9) to head (d61fb68).
:warning: Report is 1 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #3877 +/- ##
=======================================
Coverage 92.48% 92.48%
=======================================
Files 200 200
Lines 14564 14564
=======================================
Hits 13469 13469
Misses 895 895
Partials 200 200
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Thank you, @stevehipwell! Merging.