Skip to content

Commit 6bce4d1

Browse files
committed
add user-agent header; adjust auth haeader value
1 parent 5835363 commit 6bce4d1

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

cpp-linter/src/rest_api/github/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ impl RestApiClient for GithubApiClient {
100100
"Accept",
101101
HeaderValue::from_str("application/vnd.github.raw+json")?,
102102
);
103-
// headers.insert("User-Agent", USER_AGENT.parse().unwrap());
104103
if let Ok(token) = env::var("GITHUB_TOKEN") {
105-
let mut val = HeaderValue::from_str(token.as_str())?;
104+
log::debug!("Using auth token from GITHUB_TOKEN environment variable");
105+
let mut val = HeaderValue::from_str(format!("token {token}").as_str())?;
106106
val.set_sensitive(true);
107107
headers.insert(AUTHORIZATION, val);
108108
}

cpp-linter/src/rest_api/github/specific_api.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
clang_tools::{clang_format::summarize_style, ReviewComments},
1616
cli::FeedbackInput,
1717
common_fs::FileObj,
18-
rest_api::{RestApiRateLimitHeaders, COMMENT_MARKER},
18+
rest_api::{RestApiRateLimitHeaders, COMMENT_MARKER, USER_AGENT},
1919
};
2020

2121
use super::{
@@ -58,6 +58,7 @@ impl GithubApiClient {
5858
Ok(GithubApiClient {
5959
client: Client::builder()
6060
.default_headers(Self::make_headers()?)
61+
.user_agent(USER_AGENT)
6162
.build()
6263
.with_context(|| "Failed to create a session client for REST API calls")?,
6364
pull_request,

cpp-linter/src/rest_api/mod.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ use crate::cli::FeedbackInput;
2222
use crate::common_fs::{FileFilter, FileObj};
2323

2424
pub static COMMENT_MARKER: &str = "<!-- cpp linter action -->\n";
25-
pub static USER_OUTREACH: &str = "\n\nHave any feedback or feature suggestions? [Share it here.](https://github.com/cpp-linter/cpp-linter-action/issues)";
25+
pub static USER_OUTREACH: &str = concat!(
26+
"\n\nHave any feedback or feature suggestions? [Share it here.]",
27+
"(https://github.com/cpp-linter/cpp-linter-action/issues)"
28+
);
29+
pub static USER_AGENT: &str = concat!("cpp-linter/", env!("CARGO_PKG_VERSION"));
2630

2731
/// A structure to contain the different forms of headers that
2832
/// describe a REST API's rate limit status.

0 commit comments

Comments
 (0)