Skip to content

feat: configurable GitLab repository file payload encoding (text/base64)#382

Merged
zereight merged 2 commits intozereight:mainfrom
shortsteel:main
Mar 22, 2026
Merged

feat: configurable GitLab repository file payload encoding (text/base64)#382
zereight merged 2 commits intozereight:mainfrom
shortsteel:main

Conversation

@shortsteel
Copy link
Copy Markdown

Summary

Adds optional configuration for how repository file payloads are sent to the GitLab Repository API when creating/updating files, creating trees, and creating commits. The default remains text (unchanged behavior).

Motivation

Some GitLab instances or intermediaries handle large or unusual character content more reliably when the API receives encoding: "base64" with base64-encoded content. This change lets operators opt into that without forking.

What changed

  • GITLAB_REPO_FILE_ENCODINGtext (default) or base64.
  • CLI: --repo-file-encoding=text|base64 (via existing getConfig, same precedence as other flags: CLI over env).
  • encodeRepoFilePayloadContent() — when base64 is selected, string content is encoded before sending.
  • Applied consistently in createOrUpdateFile, createTree, and createCommit.
  • getFileContents: still decodes API base64 content to a plain string; no longer overwrites encoding with a fixed utf8 value after decode (aligns with API semantics).

Configuration

Mechanism Example
Environment GITLAB_REPO_FILE_ENCODING=base64
CLI --repo-file-encoding=base64

Documented in README and .env.example.

Backward compatibility

  • No config / default: same as before — text encoding and raw string content.
  • Unknown values are treated as text (only base64 enables base64 mode).

Notes for reviewers

  • Optional follow-up: add a short integration test with GITLAB_REPO_FILE_ENCODING=base64 if the project’s test harness supports it.

caoyu added 2 commits March 20, 2026 12:19
… API interactions

- Introduced GITLAB_REPO_FILE_ENCODING to specify encoding (text or base64) for file payloads.
- Updated file handling functions to utilize the new encoding option.
- Enhanced .env.example and README.md to document the new configuration.
- Changed base64 decoding to explicitly convert to UTF-8.
- Added encoding property to parsed data for clarity.
@zereight zereight merged commit 6f63bc7 into zereight:main Mar 22, 2026
6 checks passed
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.

2 participants