Skip to content

Commit

Permalink
Finish up some small feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKrol committed Nov 9, 2024
1 parent 15170fd commit 0733693
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
9 changes: 6 additions & 3 deletions backend/src/gh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
Expand All @@ -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?;
Expand Down
4 changes: 4 additions & 0 deletions backend/src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<String, String> {
let repo = self.repo.lock().unwrap();
let head = repo.head().map_err(|e| e.to_string())?;
Expand Down
11 changes: 10 additions & 1 deletion frontend/src/lib/components/BranchButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -69,7 +71,7 @@
data.data?.branches?.map((branch: string) => ({
name: branch.split(' (')[0],
isProtected: branch.includes('(protected)')
})) || []
})) ?? []
);
}
Expand Down Expand Up @@ -145,6 +147,8 @@
return;
}
showLoadingIcon = true;
// Set branch name and reset state
branchName.set(input);
newBranchName = '';
Expand All @@ -157,6 +161,7 @@
dismissible: true,
timeout: 1800
});
showLoadingIcon = false;
return;
}
Expand All @@ -172,6 +177,7 @@
type: ToastType.Error,
dismissible: true
});
showLoadingIcon = false;
return;
}
Expand All @@ -194,6 +200,7 @@
type: ToastType.Error,
dismissible: true
});
showLoadingIcon = false;
return;
}
// Fetch the updated document tree after pulling changes
Expand Down Expand Up @@ -239,6 +246,7 @@
treeResponse.statusText
);
}
showLoadingIcon = false;
}
function toggleMenu() {
Expand Down Expand Up @@ -337,6 +345,7 @@
</ul>
</div>
{/if}
<LoadingIcon bind:visible={showLoadingIcon} />
</div>

<style>
Expand Down

0 comments on commit 0733693

Please sign in to comment.