Skip to content

Commit

Permalink
Merge pull request #15 from orf/group-improvements
Browse files Browse the repository at this point in the history
Lowercase group names in github and gitlab providers
  • Loading branch information
orf authored Nov 23, 2019
2 parents f38e801 + 88abf79 commit 52d930f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/providers/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ impl fmt::Display for GithubProvider {
write!(
f,
"Github user/org {} in directory {}",
style(&self.name).green(),
style(&self.path).green()
style(&self.name.to_lowercase()).green(),
style(&self.path.to_lowercase()).green()
)
}
}
Expand Down Expand Up @@ -77,6 +77,14 @@ impl Provider for GithubProvider {
println!("Set a GITHUB_TOKEN environment variable with the value");
return false;
}
if self.name.ends_with('/') {
println!(
"{}",
style("Error: Ensure that names do not end in forward slashes").red()
);
println!("You specified: {}", self.name);
return false;
}
true
}

Expand All @@ -89,7 +97,7 @@ impl Provider for GithubProvider {

loop {
let q = Repositories::build_query(repositories::Variables {
login: self.name.clone(),
login: self.name.to_lowercase(),
after,
});
let res = ureq::post("https://api.github.com/graphql")
Expand Down
12 changes: 10 additions & 2 deletions src/providers/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl fmt::Display for GitlabProvider {
write!(
f,
"Gitlab user/group {} at {} in directory {}",
style(&self.name).green(),
style(&self.name.to_lowercase()).green(),
style(&self.url).green(),
style(&self.path).green()
)
Expand All @@ -95,6 +95,14 @@ impl Provider for GitlabProvider {
println!("Set a GITLAB_TOKEN environment variable with the value");
return false;
}
if self.name.ends_with('/') {
println!(
"{}",
style("Error: Ensure that names do not end in forward slashes").red()
);
println!("You specified: {}", self.name);
return false;
}
true
}
fn fetch_repositories(&self) -> Result<Vec<Repository>, Error> {
Expand All @@ -104,7 +112,7 @@ impl Provider for GitlabProvider {
let mut after = Some("".to_string());
loop {
let q = Repositories::build_query(repositories::Variables {
name: self.name.to_string(),
name: self.name.to_string().to_lowercase(),
after,
});
let res = ureq::post(format!("{}/api/graphql", self.url).as_str())
Expand Down

0 comments on commit 52d930f

Please sign in to comment.