Skip to content

Commit e60d079

Browse files
committed
feat: add env::agent() for obtaining the default client agent string.
1 parent 121c93f commit e60d079

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

git-repository/src/env.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
//! Utilities to handle program arguments and other values of interest.
12
use std::ffi::{OsStr, OsString};
23

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

6+
/// Returns the name of the agent for identification towards a remote server as statically known when compiling the crate.
7+
/// Suitable for both `git` servers and HTTP servers, and used unless configured otherwise.
8+
///
9+
/// Note that it's meant to be used in conjunction with [`protocol::fetch::agent()`][crate::protocol::fetch::agent()] which
10+
/// prepends `git/`.
11+
pub fn agent() -> &'static str {
12+
concat!("oxide-", env!("CARGO_PKG_VERSION"))
13+
}
14+
515
/// Equivalent to `std::env::args_os()`, but with precomposed unicode on MacOS and other apple platforms.
616
#[cfg(not(target_vendor = "apple"))]
717
pub fn args_os() -> impl Iterator<Item = OsString> {

git-repository/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ pub mod state {
338338
///
339339
pub mod discover;
340340

341-
///
342341
pub mod env;
343342

344343
mod kind;

0 commit comments

Comments
 (0)