Skip to content

feat: add Cred feature with recipe pattern and replace Credential DTO in remote options#195

Open
racgoo wants to merge 5 commits intotoss:mainfrom
racgoo:feat/cred
Open

feat: add Cred feature with recipe pattern and replace Credential DTO in remote options#195
racgoo wants to merge 5 commits intotoss:mainfrom
racgoo:feat/cred

Conversation

@racgoo
Copy link
Contributor

@racgoo racgoo commented Mar 7, 2026

cred feature in #94

@seokju-na I wasn't assigned to this issue yet, but I wanted to give it a try. Please let me know if the approach looks good or if anything needs to be changed.

Summary

  • Adds Cred class with factory methods (default(), sshKeyFromAgent(), sshKey(), sshKeyFromMemory(), userpassPlaintext(), username(), credentialHelper()) and CredType enum.
  • git2::Cred does not implement Clone or Send, so it cannot be reused across callbacks or moved into async tasks. Instead, Cred stores only the parameters needed to build a git2::Cred (recipe pattern). A fresh git2::Cred is created from the recipe each time it is needed, making Cred freely cloneable and safe to send across threads.
  • Removes the Credential DTO and CredentialType enum from remote.rs.
    FetchOptions, PushOptions, and PruneOptions now take Cred directly in their credential field. Credential was a flat object that held all possible fields at once (e.g. privateKeyPath was present even for a plain username/password credential), which made it unclear which fields were actually required for each credential type.
  • All factory methods are infallible and return Cred directly. Errors only surface when the credential is actually used (e.g. during network I/O or hasUsername()).

Breaking changes

Before After
FetchOptions.credential: Credential | null FetchOptions.credential: Cred | null
PushOptions.credential: Credential | null PushOptions.credential: Cred | null
Factory methods throw on failure Factory methods never throw

racgoo added 5 commits March 3, 2026 23:47
TODO: Credential struct is a flat DTO mixing all credential fields regardless
of type. Consider replacing it with a builder pattern where callers construct
Cred directly via factory methods (Cred.default(), Cred.sshKeyFromAgent(), etc.)
and inject it into fetch/push options — eliminating the Credential struct entirely.
@racgoo racgoo requested a review from seokju-na as a code owner March 7, 2026 08:39
@vercel
Copy link

vercel bot commented Mar 7, 2026

@racgoo is attempting to deploy a commit to the Toss Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant