Skip to content

Commit

Permalink
Merge branch 'release/v0.1.4' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kilpkonn committed May 7, 2021
2 parents 0627d13 + 5419a50 commit 5933455
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gtm-sync"
version = "0.1.0"
version = "0.1.4"
authors = ["tavo <[email protected]>"]
edition = "2018"

Expand All @@ -14,8 +14,8 @@ serde_json = "1.0.44"
toml = "0.5.7"
regex = "1"
lazy_static = "1.4.0"
reqwest = { version = "0.10.9", features = ["json"] }
tokio = { version = "0.2", features = ["full"] }
reqwest = { version = "0.11", features = ["json"] }
tokio = { version = "1.5", features = ["full"] }
log = "0.4.14"

[dependencies.rocket_contrib]
Expand Down
10 changes: 5 additions & 5 deletions src/server/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ pub fn repo(provider: String, user: String, repo: String) -> JsonValue {

#[post("/repositories", data="<repo>")]
pub fn add_repo(repo: Json<AddRepositoryDto>) -> JsonValue {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
let response = rt.block_on(repo_manager::add_repo(repo.into_inner()));
rocket_contrib::json!(&response)
}

#[get("/repositories/sync-all")]
pub fn sync_all() -> JsonValue {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
let response = rt.block_on(sync::sync_all());
rocket_contrib::json!(&response)
}

#[get("/repositories/<provider>/<user>/<repo>/sync")]
pub fn sync_repo(provider: String, user: String, repo: String) -> JsonValue {
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
let response = rt.block_on(sync::sync_repo(&provider, &user, &repo));
rocket_contrib::json!(&response)
}
Expand All @@ -42,7 +42,7 @@ pub fn post_sync_repo(provider: String, user: String, repo: String) -> JsonValue
pub fn sync_repo_github(dto: Json<GithubPushWebhook>) -> JsonValue {
let dto = dto.into_inner();
let (provider, user, repo) = generate_credentials_from_clone_url(&dto.repository.ssh_url);
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(sync::sync_repo(&provider, &user, &repo));
rocket_contrib::json!({})
}
Expand All @@ -51,7 +51,7 @@ pub fn sync_repo_github(dto: Json<GithubPushWebhook>) -> JsonValue {
pub fn sync_repo_gitlab(dto: Json<GitlabPushWebhook>) -> JsonValue {
let dto = dto.into_inner();
let (provider, user, repo) = generate_credentials_from_clone_url(&dto.repository.git_ssh_url);
let mut rt = tokio::runtime::Runtime::new().unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(sync::sync_repo(&provider, &user, &repo));
rocket_contrib::json!({})
}
2 changes: 1 addition & 1 deletion src/sync/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn fetch_synced_hashes(
api_key: &str,
) -> Result<LastSyncResponse, reqwest::Error> {
let (provider, user, repo) = generate_credentials_from_clone_url(&repo.url);
let url = format!("{}/api/commits/{}/{}/{}/hash", target_host, provider, user, repo);
let url = format!("{}/api/commits/hash?provider={}&user={}&repo={}", target_host, provider, user, repo);

return Ok(client.get(&url)
.header("API-key", api_key)
Expand Down

0 comments on commit 5933455

Please sign in to comment.