From 0733693eaacf799f097efa58887d78b56cd3a166 Mon Sep 17 00:00:00 2001 From: TheKrol Date: Sat, 9 Nov 2024 08:52:44 -0500 Subject: [PATCH] Finish up some small feedback --- backend/src/gh.rs | 9 ++++++--- backend/src/git.rs | 4 ++++ frontend/src/lib/components/BranchButton.svelte | 11 ++++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/backend/src/gh.rs b/backend/src/gh.rs index 5f17bbf..eb5053e 100644 --- a/backend/src/gh.rs +++ b/backend/src/gh.rs @@ -12,7 +12,7 @@ use std::io::Read; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; use tokio::sync::Mutex; -use tracing::{ info, error }; +use tracing::{ info, error, debug }; const GITHUB_API_URL: &str = "https://api.github.com"; @@ -247,7 +247,7 @@ pub async fn create_pull_request( "body": pr_description, }); - info!("Creating pull request to {}/repos/{}/pulls", GITHUB_API_URL, repo_name); + debug!("Creating pull request to {}/repos/{}/pulls", GITHUB_API_URL, repo_name); // Send the pull request creation request to the GitHub API let response = reqwest_client @@ -260,7 +260,10 @@ pub async fn create_pull_request( // Handle the response based on the status code if response.status().is_success() { - info!("Pull request created successfully for branch {}", head_branch); + info!( + "Pull request created to merge {} into {}", + head_branch, base_branch + ); // Extract the response JSON to get the pull request URL let response_json: Value = response.json().await?; diff --git a/backend/src/git.rs b/backend/src/git.rs index 3300f84..930bfe5 100644 --- a/backend/src/git.rs +++ b/backend/src/git.rs @@ -371,6 +371,8 @@ impl Interface { /// - The current HEAD reference cannot be retrieved. /// - The branch cannot be found or created. /// - The HEAD cannot be set to the specified branch. + #[allow(clippy::significant_drop_tightening)] + #[allow(clippy::cognitive_complexity)] pub fn checkout_or_create_branch(&self, branch_name: &str) -> Result<()> { debug!("Attempting to checkout or create branch: {}", branch_name); @@ -518,6 +520,7 @@ impl Interface { /// - The specified branch does not exist. /// - There are issues with resetting the repository or finding references. /// - Fetching changes from the remote repository fails. + #[allow(clippy::significant_drop_tightening)] #[tracing::instrument(skip(self))] pub fn git_pull_branch(&self, branch: &str) -> Result<()> { // Lock and check the repository @@ -869,6 +872,7 @@ impl Interface { /// /// # Errors /// - If the repository is unavailable or the `head()` operation fails, an error is returned with a description of the failure. + #[allow(clippy::significant_drop_tightening)] pub async fn get_current_branch(&self) -> Result { let repo = self.repo.lock().unwrap(); let head = repo.head().map_err(|e| e.to_string())?; diff --git a/frontend/src/lib/components/BranchButton.svelte b/frontend/src/lib/components/BranchButton.svelte index dfc3961..a4432bd 100644 --- a/frontend/src/lib/components/BranchButton.svelte +++ b/frontend/src/lib/components/BranchButton.svelte @@ -12,10 +12,12 @@ import { ToastType, addToast } from '$lib/toast'; import { cache } from '$lib/cache'; import type { Branch } from '$lib/types'; + import LoadingIcon from './elements/LoadingIcon.svelte'; let showMenu = false; let newBranchName: string = ''; let showInput = false; + let showLoadingIcon: boolean; /** * Fetches the list of branches from the GitHub API, categorizing them as protected or non-protected. @@ -69,7 +71,7 @@ data.data?.branches?.map((branch: string) => ({ name: branch.split(' (')[0], isProtected: branch.includes('(protected)') - })) || [] + })) ?? [] ); } @@ -145,6 +147,8 @@ return; } + showLoadingIcon = true; + // Set branch name and reset state branchName.set(input); newBranchName = ''; @@ -157,6 +161,7 @@ dismissible: true, timeout: 1800 }); + showLoadingIcon = false; return; } @@ -172,6 +177,7 @@ type: ToastType.Error, dismissible: true }); + showLoadingIcon = false; return; } @@ -194,6 +200,7 @@ type: ToastType.Error, dismissible: true }); + showLoadingIcon = false; return; } // Fetch the updated document tree after pulling changes @@ -239,6 +246,7 @@ treeResponse.statusText ); } + showLoadingIcon = false; } function toggleMenu() { @@ -337,6 +345,7 @@ {/if} +