Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): handle case of deleted remote branch in log command #29

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/src/clients/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ impl Git {
// per update.
let mut line = line;

if line.starts_with("Updating files") {
if line.contains("Updating files") {
line = "Updating files...".to_string();
}

Expand Down
10 changes: 9 additions & 1 deletion core/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anyhow::bail;
use async_trait::async_trait;
use chrono::DateTime;
use reqwest::StatusCode;
use tracing::{error, info};
use tracing::{debug, error, info};

#[derive(Clone)]
pub struct CommitOp {
Expand Down Expand Up @@ -68,6 +68,14 @@ impl LogOp {
true => self.repo_status.read().remote_branch.clone(),
false => self.repo_status.read().branch.clone(),
};

// Sometimes we ask for the remote branch's log, but the branch may be deleted as part
// of the pull request process. In this case, we should return an empty log.
if git_ref.is_empty() {
debug!("Branch is empty, returning empty log");
return Ok(vec![]);
}

let output = self.git_client.log(self.limit, &git_ref).await?;
let result = output
.lines()
Expand Down
Loading