Skip to content

Commit

Permalink
fix: use GITHUB_API_TOKEN or GITHUB_TOKEN (#2815)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: mise[bot] <[email protected]>
  • Loading branch information
jdx and mise-en-dev authored Oct 25, 2024
1 parent 1e3cbc3 commit 51fb031
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/cli/self_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl SelfUpdate {

fn fetch_releases(&self) -> Result<Vec<Release>> {
let mut releases = ReleaseList::configure();
if let Some(token) = &*env::GITHUB_API_TOKEN {
if let Some(token) = &*env::GITHUB_TOKEN {
releases.auth_token(token);
}
let releases = releases
Expand All @@ -82,7 +82,7 @@ impl SelfUpdate {
.map(|v| format!("v{}", v))?;
let target = format!("{}-{}", *OS, *ARCH);
let mut update = Update::configure();
if let Some(token) = &*env::GITHUB_API_TOKEN {
if let Some(token) = &*env::GITHUB_TOKEN {
update.auth_token(token);
}
if self.force || self.version.is_some() {
Expand Down
2 changes: 0 additions & 2 deletions src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ pub static PATH_NON_PRISTINE: Lazy<Vec<PathBuf>> = Lazy::new(|| match var(&*PATH
Err(_) => vec![],
});
pub static DIRENV_DIFF: Lazy<Option<String>> = Lazy::new(|| var("DIRENV_DIFF").ok());
#[allow(unused)]
pub static GITHUB_API_TOKEN: Lazy<Option<String>> = Lazy::new(|| var("GITHUB_API_TOKEN").ok());
pub static GITHUB_TOKEN: Lazy<Option<String>> = Lazy::new(|| {
var("GITHUB_TOKEN")
.or_else(|_| var("GITHUB_API_TOKEN"))
Expand Down
2 changes: 1 addition & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Client {
debug!("GET {}", &url);
let mut req = self.reqwest.get(url.clone());
if url.host_str() == Some("api.github.com") {
if let Some(token) = &*env::GITHUB_API_TOKEN {
if let Some(token) = &*env::GITHUB_TOKEN {
req = req.header("authorization", format!("token {}", token));
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/task/task_script_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ pub fn replace_template_placeholders_with_args(
.collect::<Vec<_>>();
let m = usage::parse(spec, &args).map_err(|e| eyre::eyre!(e.to_string()))?;
let mut out = vec![];
let re = regex!(r"MISE_TASK_ARG:(\w+):MISE_TASK_ARG");
for script in scripts {
let mut script = script.clone();
for (arg, value) in &m.args {
Expand All @@ -306,9 +307,7 @@ pub fn replace_template_placeholders_with_args(
&value.to_string(),
);
}
script = regex!(r"MISE_TASK_ARG:(\w+):MISE_TASK_ARG")
.replace_all(&script, "")
.to_string();
script = re.replace_all(&script, "").to_string();
out.push(script);
}
Ok(out)
Expand Down

0 comments on commit 51fb031

Please sign in to comment.