git-ca 0.2.3

git plugin that drafts commit messages using GitHub Copilot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
pub mod codex;
pub mod copilot_token;
pub mod device_flow;
pub mod store;

pub use store::AuthFile;

use crate::error::Result;

/// Load the auth file and return a valid Copilot token, exchanging/refreshing
/// transparently. Returns the file so callers can persist further changes
/// (e.g. after a forced refresh on 401).
pub async fn ensure_copilot_token(http: &reqwest::Client) -> Result<(String, AuthFile)> {
    let mut file = AuthFile::load()?;
    let token = copilot_token::ensure(http, copilot_token::GITHUB_API_BASE, &mut file).await?;
    Ok((token, file))
}