Skip to main content

Crate gitpoulpi_hosting

Crate gitpoulpi_hosting 

Source
Expand description

Hosting and issue-tracker API clients: GitHub, GitLab, Gitea/Forgejo, Azure DevOps, Bitbucket, Gerrit, Jira, Trello, Linear, YouTrack, Redmine and local Markdown issues, including self-managed instances.

Two jobs:

  1. List the projects a token can see, and clone straight from that list. HostingClient::list_projects returns a normalized HostedProject whichever host produced it, and HostedProject::clone_url hands the chosen row’s URL to GitBackend::clone.
  2. Generate an SSH key and upload it. ssh_key makes the pair in process (no ssh-keygen dependency, no prompt), and HostingClient::upload_ssh_key registers the public half.

Every network call goes through http::HttpTransport, so the crate is testable with no network (http::RecordedTransport); only ReqwestTransport, behind the default network feature, opens a socket.

An integration is a base URL plus a token reference, and the API root is derived from the base URL (see Integration::api_base) rather than configured separately, because two keys that must agree can disagree.

Re-exports§

pub use account::AccountCache;
pub use account::AccountIssue;
pub use account::AccountItems;
pub use account::AccountPr;
pub use account::AccountQuery;
pub use account::CachedAccount;
pub use account::ACCOUNT_TTL;
pub use account::ACCOUNT_TTL_SECS;
pub use auth::auth_headers;
pub use auth::git_username;
pub use client::client_for;
pub use client::issue_web_url;
pub use client::pull_request_edit_url;
pub use client::pull_request_head_ref;
pub use client::pull_request_web_url;
pub use client::token_create_url;
pub use client::web_base as integration_web_base;
pub use client::CreatedIssue;
pub use client::CreatedPullRequest;
pub use client::HostingClient;
pub use client::NewIssue;
pub use client::NewPullRequest;
pub use client::UnsupportedClient;
pub use conditional::shared_network_transport;
pub use conditional::shared_rate_note;
pub use conditional::ConditionalTransport;
pub use github::GitHubClient;
pub use gitlab::GitLabClient;
pub use http::ReqwestTransport;
pub use http::HttpBytes;
pub use http::HttpRequest;
pub use http::HttpResponse;
pub use http::HttpTransport;
pub use http::Method;
pub use http::RecordedTransport;
pub use issue_flow::CreatedBranch;
pub use issue_flow::NewIssueBranch;
pub use metadata::list_delta;
pub use metadata::HostedLabel;
pub use metadata::HostedMilestone;
pub use metadata::IssueEdit;
pub use metadata::ItemMeta;
pub use metadata::MetaKind;
pub use metadata::PrEdit;
pub use model::best_pull_request;
pub use model::excess_scopes;
pub use model::is_dangerous_scope;
pub use model::ChecksState;
pub use model::Choice;
pub use model::HostedUser;
pub use model::IssueCreateOptions;
pub use model::IssueFilter;
pub use model::IssueState;
pub use model::IssueSummary;
pub use model::PrFilter;
pub use model::PullRequestState;
pub use model::PullRequestSummary;
pub use model::StateFilter;
pub use model::TokenCheck;
pub use model::TokenFlavor;
pub use request_actions::request_actions;
pub use request_actions::strip_draft_prefix;
pub use request_actions::MergeMethod;
pub use request_actions::RequestActions;
pub use resolve::resolve_for_repo;
pub use resolve::suggest_for_repo;
pub use resolve::Resolution;
pub use resolve::ResolveRemote;
pub use resolve::Suggestion;
pub use review::review_base_ref;
pub use review::review_base_refspec;
pub use review::review_compare_ref;
pub use review::review_compare_refspec;
pub use review::review_head_ref;
pub use review::review_head_refspec;
pub use review::review_head_refspec_at;
pub use review::DiffSide;
pub use review::FileStatus;
pub use review::MergeState;
pub use review::PatchSet;
pub use review::PendingComment;
pub use review::PullRequestDetail;
pub use review::ReviewCapabilities;
pub use review::ReviewComment;
pub use review::ReviewEvent;
pub use review::ReviewFile;
pub use review::ReviewOutcome;
pub use review::ReviewState;
pub use review::ReviewSubmission;
pub use review::ReviewThread;
pub use review::ReviewVote;
pub use review::SubmittedReview;
pub use review::VoteLabel;
pub use review::VoteValue;
pub use scope::install as install_repo_scopes;
pub use scope::RepoScopes;
pub use spec::CheckoutSource;
pub use spec::spec_for;
pub use spec::FamilySpec;
pub use spec::RemoteRef;
pub use trust::Account;
pub use trust::TrustGate;
pub use trust::TrustProblem;
pub use trust::TrustSubject;

Modules§

account
Account-wide lists: the requests waiting for my review, every open request of my namespaces and the issues assigned to me, across every repository of a host rather than the one folder a scope is about.
auth
Which request headers carry a token, per integration kind. Pure: no I/O, so every scheme is a table-test row.
azure_devops
Azure DevOps (Services and Server) hosting client: repositories, pull requests and Boards work items (the “issues” half), over a personal access token.
bitbucket
Bitbucket Cloud hosting client (slice S4).
board
The Kanban board’s column logic (slice L2): which columns an issue source has, which column each issue sits in, what a move changes, and the board filters. Pure data in, pure data out: no IO and no UI, so the TUI, a CLI and a provider added later (Linear, YouTrack) share it.
cache_search
The workspace search’s hosting kinds: pull/merge requests and issues found in a repository’s on-disk hosting cache (hosting-cache.json, the snapshot the TUI keeps beside repo-state.toml), never from a host.
client
The provider-agnostic hosting port and its plumbing.
conditional
Conditional requests and rate-limit back-off, as a transport decorator.
conversation
Reading and writing the conversation of an issue or a pull / merge request: its header, comments, system events and code threads, and posting, replying, editing and deleting as the identity the token has.
flow_engine
Host-driven flows, the shared engine of the CLI, the MCP server and the TUI: create the issue, make the branch on the host, find what the host or a bot made for an issue, wait for it. Everything here is a function over a HostingClient, so a fake transport tests it and the three frontends cannot drift apart. The loops (sleeping, cancelling, drawing a spinner) are the frontend’s: it asks find_for_issue again after backoff.
gerrit
Gerrit Code Review client (slice T3): the review view’s host for patch-set based review. Review only: Gerrit has no issues, and a change is created by pushing to refs/for/<branch>, never by an API call.
gitea
Gitea and Forgejo (incl. Codeberg) hosting client (integrations wave 2, slice G). One client for both kinds: Forgejo is a Gitea fork whose REST API (/api/v1) stayed compatible.
github
The GitHub client (github.com and GitHub Enterprise Server).
gitlab
The GitLab client (gitlab.com and self-managed).
http
The HTTP seam.
issue_flow
Host-driven flows (slice W4): what the host can make from an issue and what it already made for one. The types are provider-agnostic; the providers fill them (gitlab_flow.rs, github_flow.rs, gitea/flow.rs).
jira
Jira (Cloud and Data Center) issue-tracker client (slice S5).
linear
Linear issue-tracker client (slice T1).
list_cache
A saved copy of an integration’s repository list, so the Clone dialog shows it at once while a fresh request runs.
local_markdown
Local Markdown issues (slice L1): a folder of notes, one per issue, usable with an Obsidian vault. No token and no network.
markup
Markup conversion for issue and pull-request text (plan conversations).
metadata
Assignees, reviewers, labels and milestones: the host-agnostic shapes the pickers (TUI), pr edit / issue edit (CLI/MCP) and the create forms speak. GitHub and GitLab fill them (github_meta, gitlab_meta); every other provider keeps the Unsupported defaults of the trait and nothing about it shows in a UI.
model
Host-agnostic shapes for the account, pull/merge request and issue queries. Normalised here, once, so the TUI/CLI/MCP never see whether a row came from GitHub or GitLab.
protection
What a host protects (S23 of the history rewrite): the branches a rewrite must not force-push unless the user lifts the protection first.
redmine
Redmine issue-tracker client (slice T2).
refs
References in commit messages and branch names (plan D7).
request_actions
Merging and closing a pull / merge request on the host.
resolve
Which configured profile answers questions about a repository.
review
In-app code review of pull / merge requests (GitHub incl. Enterprise, GitLab incl. self-managed): reading a request, its changed files, its threads and conversation; commenting, replying, resolving; submitting a review. The diff itself comes from git, not from here (see model’s module docs for how positions map onto it).
scope
Per-repository decisions the hosting clients honour without every caller passing a repository: which token a repository’s host calls use (a token command, for a GitHub App bot) and whether assignment is blocked.
spec
The per-family descriptor table (plan more-providers.md, D1).
ssh_key
Generating an SSH key pair, in process.
trello
Trello issue-tracker client (slice S6).
trust
Integration trust: what a token (or an AI key) may be sent to.
updates
Looking for a newer GitPoulpi release (the updates-and-install design, slice A).
xrefs
Cross references in issue and pull-request text (plan conversations, 4c).
youtrack
YouTrack (Cloud and Server) issue-tracker client (slice T1).

Structs§

DefaultTokenSource
The default resolution order, per profile:
HostedProject
HostedSshKey
An SSH public key as the host holds it.
Integration
One configured profile. token_ref is a key into gitpoulpi-secrets, never a token.
PullRequestForm
What the “new pull / merge request” form is prefilled with.
StaticToken
A token held in memory. For tests, and for a CLI invocation that was handed one on the command line.

Enums§

Error
IntegrationKind
Which product a profile talks to. Spellings are snake_case and pinned by tests: they are written to disk.

Constants§

MAX_URL_LEN
Longest URL produced; browsers and hosts refuse far less than ~8 kB (GitHub answers 414 above it), so the description is cut to fit.
TRUNCATION_NOTE
Appended to a description that had to be cut.

Traits§

TokenSource
Where a token comes from. A trait so the clients can be tested with a canned token and the resolution order can change without touching a client.

Functions§

match_integration
Which configured instance a remote URL belongs to, so a repository’s origin can be linked back to the integration that can answer questions about it.
new_issue_form_url
The provider’s “new issue” form for project, prefilled.
new_pull_request_form_url
The provider’s “new pull / merge request” form, prefilled.
new_pull_request_url
Builds the “open a compare/new pull-request page” URL by hand: the no-token fallback, and what a token-holding flow opens on success too (see client::HostingClient::create_pull_request).
percent_encode_component
Percent-encodes a query component: everything but RFC 3986 unreserved.
remote_web_base
Splits a git remote URL into the host’s web base (https://host, never the API root) and the project path (group/sub/proj), for building a pull/merge-request URL by hand.
resolve_local_folder
A repository-relative folder made absolute; an absolute one is kept and ~/ is expanded. How a local Markdown issue source’s folder is read.
token_env_var
The environment variable an integration’s token can be supplied in (CI, a one-off shell), without writing it to disk.
web_base_for
web_base (from remote_web_base), moved to the address the matched profile says the server lives at when it is the same host: an ssh remote of a server configured as http://host:3000 opens its web pages there, not on https://host.
well_known_kind
The two hosts recognized with no configuration at all: github.com / gitlab.com (or a *.github.com / *.gitlab.com subdomain), so a remote with no matching [[integrations]] entry still gets a usable compare/new-request URL.

Type Aliases§

Result