Skip to content

Commit

Permalink
Merge branch 'main' into github-client
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKrol committed Jan 13, 2025
2 parents 2439a40 + c9462d2 commit e701fc2
Show file tree
Hide file tree
Showing 36 changed files with 1,011 additions and 1,339 deletions.
250 changes: 101 additions & 149 deletions backend/Cargo.lock

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ categories = ["web-programming"]
rust-version = "1.75.0"

[dependencies]
axum = { version = "0.7.9", features = ["http2", "macros"] }
chrono = "0.4.38"
clap = { version = "4.5.21", features = ["derive"] }
axum = { version = "0.8.1", features = ["http2", "macros"] }
chrono = "0.4.39"
clap = { version = "4.5.23", features = ["derive"] }
color-eyre = "0.6.3"
dotenvy = "0.15.7"
fs-err = { version = "3.0.0", features = ["tokio"] }
git2 = "0.19.0"
git2 = "0.20.0"
jsonwebtoken = "9.3.0"
oauth2 = "4.4.2"
reqwest = { version = "0.12.9", features = ["stream", "json"] }
serde = { version = "1.0.215", features = ["derive"] }
serde_json = "1.0.133"
sqlx = { version = "0.8.1", features = ["sqlite", "runtime-tokio"] }
tokio = { version = "1.41.1", features = ["macros", "rt-multi-thread", "signal", "tracing"] }
tower-http = { version = "0.6.1", features = ["normalize-path", "fs", "cors", "tracing", "trace"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.134"
sqlx = { version = "0.8.3", features = ["sqlite", "runtime-tokio"] }
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread", "signal", "tracing"] }
tower-http = { version = "0.6.2", features = ["normalize-path", "fs", "cors", "tracing", "trace"] }
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
toml = "0.8.19"
1 change: 0 additions & 1 deletion backend/src/gh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ impl GitHubClient {
base_branch: Option<&str>,
issue_numbers: Option<Vec<u64>>,
) -> Result<String> {
info!("Made it to the start of the update PR");
let repo_name = self.get_repo_name()?;
let token = self.get_token().await?;
let mut pr_body_json = serde_json::Map::new();
Expand Down
21 changes: 17 additions & 4 deletions backend/src/handlers_prelude/github_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ pub async fn update_pull_request_handler(
Json(payload): Json<UpdatePRRequest>,
) -> Result<(StatusCode, Json<ApiResponse<String>>), (StatusCode, String)> {

// Get the GitHub access token
let token = get_github_token(&state).await.map_err(|err| {
let error_message = format!("Failed to get GitHub token: {:?}", err);
(StatusCode::INTERNAL_SERVER_ERROR, error_message)
})?;

// Create an instance of the GitHubClient
let github_client = GitHubClient::new(
state.config.files.repo_url.clone(),
state.reqwest_client.clone(),
token,
);

// Update the pull request
match state
.gh_client
Expand Down Expand Up @@ -355,11 +368,11 @@ pub async fn github_routes() -> Router<AppState> {
Router::new()
.route("/branches", get(list_branches_handler))
.route("/pulls", post(create_pull_request_handler))
.route("/checkout/branches/:branch_name", put(checkout_or_create_branch_handler))
.route("/checkout/branches/{branch_name}", put(checkout_or_create_branch_handler))
.route("/pulls/update", put(update_pull_request_handler))
.route("/pull-requests/:pr_number/close", post(close_pull_request_handler))
.route("/pull/:branch", post(pull_handler))
.route("/pull-requests/{pr_number}/close", post(close_pull_request_handler))
.route("/pull/{branch}", post(pull_handler))
.route("/current-branch", get(get_current_branch_handler))
.route("/issues/:state", get(get_issues_handler))
.route("/issues/{state}", get(get_issues_handler))
.route("/repos/default-branch", get(get_default_branch_handler))
}
4 changes: 2 additions & 2 deletions backend/src/handlers_prelude/groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ pub async fn delete_group_handler(
pub async fn create_group_route() -> Router<AppState> {
Router::new()
.route("/groups", get(get_groups_handler).post(post_group_handler))
.route("/groups/:group_id", delete(delete_group_handler))
.route("/groups/{group_id}", delete(delete_group_handler))
.route(
"/groups/:group_id/permissions",
"/groups/{group_id}/permissions",
put(put_group_permissions_handler),
)
}
2 changes: 1 addition & 1 deletion backend/src/handlers_prelude/repo_fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub async fn create_tree_route() -> Router<AppState> {
)
.route("/tree/asset", get(get_asset_tree_handler))
.route(
"/asset/*path",
"/asset/{*path}",
get(get_asset_handler)
.put(put_asset_handler)
.delete(delete_asset_handler),
Expand Down
4 changes: 2 additions & 2 deletions backend/src/handlers_prelude/users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ pub async fn create_user_route() -> Router<AppState> {
Router::new()
.route("/users", get(get_users_handler))
.route(
"/users/groups/:user_id",
"/users/groups/{user_id}",
post(post_user_membership_handler).delete(delete_user_membership_handler),
)
.route("/users/:user_id", delete(delete_user_handler))
.route("/users/{user_id}", delete(delete_user_handler))
.route(
"/users/me",
get(get_current_user_handler).delete(delete_current_user),
Expand Down
3 changes: 1 addition & 2 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ async fn start_server(state: AppState, cli_args: Args) -> Result<()> {
ServeDir::new(format!("repo/{asset_path}")),
)
// Serve the frontend files
.nest_service(
"/",
.fallback_service(
ServeDir::new(frontend_dir)
.precompressed_br()
.precompressed_gzip(),
Expand Down
Loading

0 comments on commit e701fc2

Please sign in to comment.