Skip to content

Commit

Permalink
feat: add env::agent() for obtaining the default client agent string.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 10, 2022
1 parent 121c93f commit e60d079
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 10 additions & 0 deletions git-repository/src/env.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
//! Utilities to handle program arguments and other values of interest.
use std::ffi::{OsStr, OsString};

use crate::bstr::{BString, ByteVec};

/// Returns the name of the agent for identification towards a remote server as statically known when compiling the crate.
/// Suitable for both `git` servers and HTTP servers, and used unless configured otherwise.
///
/// Note that it's meant to be used in conjunction with [`protocol::fetch::agent()`][crate::protocol::fetch::agent()] which
/// prepends `git/`.
pub fn agent() -> &'static str {
concat!("oxide-", env!("CARGO_PKG_VERSION"))
}

/// Equivalent to `std::env::args_os()`, but with precomposed unicode on MacOS and other apple platforms.
#[cfg(not(target_vendor = "apple"))]
pub fn args_os() -> impl Iterator<Item = OsString> {
Expand Down
1 change: 0 additions & 1 deletion git-repository/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ pub mod state {
///
pub mod discover;

///
pub mod env;

mod kind;

0 comments on commit e60d079

Please sign in to comment.