Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Oct 25, 2024
1 parent 4f978ad commit d3ca7ed
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 41 deletions.
36 changes: 0 additions & 36 deletions src/ctx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,42 +49,6 @@ impl<'a> StContext<'a> {
}
}

/// Returns if the current branch has an open PR.
/// Returns the branch name and it's parent branch name.
pub async fn get_open_pr(&self, client: &Octocrab) -> StResult<Option<(String, String)>> {
let (owner, repo) = self.owner_and_repository()?;
let page = client
.pulls(&owner, &repo)
.list()
.state(octocrab::params::State::Open)
.sort(octocrab::params::pulls::Sort::Popularity)
.direction(octocrab::params::Direction::Ascending)
.per_page(255)
.send()
.await?;
let mut found = false;
let current_branch = self.repository.current_branch_name()?;
for item in page.items.iter() {
if item.head.ref_field == current_branch {
found = true;
break;
}
}
if found {
let current_tracked_branch = self
.tree
.get(&current_branch)
.ok_or_else(|| StError::BranchNotTracked(current_branch.to_string()))?;
let upstack = current_tracked_branch.parent.as_ref();
return Ok(Some((
current_branch,
upstack.map(|s| s.as_ref()).unwrap_or("unknown").to_string(),
)));
}

Ok(None)
}

/// Loads the [StackTree] for the given [Repository], and assembles a [StContext].
pub fn try_load(cfg: StConfig, repository: &'a Repository) -> StResult<Option<Self>> {
let store_path = ctx_path(repository).ok_or(StError::GitRepositoryRootNotFound)?;
Expand Down
3 changes: 0 additions & 3 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ pub enum StError {
/// A remote pull request could not be found.
#[error("Remote pull request not found.")]
PullRequestNotFound,
/// A pull request is already open.
#[error("Pull request is already open for branch {} with parent `{}`.", Color::Blue.paint(.0), Color::Blue.paint(.1))]
PullRequestAlreadyOpen(String, String),

// ---- [ Git Errors ] ----
/// `st` mused be run within a git repository.
Expand Down
3 changes: 1 addition & 2 deletions src/subcommands/remote/submit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ impl SubmitCmd {

// Perform pre-flight checks.
println!("🔍 Checking for closed pull requests...");
self.pre_flight(&mut ctx, &stack, &mut pulls)
.await?;
self.pre_flight(&mut ctx, &stack, &mut pulls).await?;

// Submit the stack.
println!(
Expand Down

0 comments on commit d3ca7ed

Please sign in to comment.