Skip to content

Commit

Permalink
add list_commit_files to CLI
Browse files Browse the repository at this point in the history
This should facilitate looking at what the UI currently expects for patches.
  • Loading branch information
Byron committed Jan 21, 2025
1 parent 562a4d2 commit 93b838c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/gitbutler-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gitbutler-command-context.workspace = true
gitbutler-branch.workspace = true
gitbutler-diff.workspace = true
gitbutler-stack.workspace = true
gitbutler-oxidize.workspace = true
gix = { workspace = true, features = ["max-performance", "tracing"] }
dirs-next = "2.0.0"
clap = { version = "4.5.23", features = ["derive", "env"] }
Expand Down
5 changes: 5 additions & 0 deletions crates/gitbutler-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ pub mod vbranch {
/// The name of the remote branch to integrate with, like `origin/main`.
short_tracking_branch_name: String,
},
/// List all changes of a commit, along with their patches.
ListCommitFiles {
/// The hex-id of the commit to produce information for.
commit_id: String,
},
/// Make the named branch the default so all worktree or index changes are associated with it automatically.
SetDefault {
/// The name of the new default virtual branch.
Expand Down
9 changes: 9 additions & 0 deletions crates/gitbutler-cli/src/command/vbranch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,21 @@ use anyhow::{bail, Context, Result};
use gitbutler_branch::{BranchCreateRequest, BranchIdentity, BranchUpdateRequest};
use gitbutler_branch_actions::{get_branch_listing_details, list_branches, BranchManagerExt};
use gitbutler_command_context::CommandContext;
use gitbutler_oxidize::ObjectIdExt;
use gitbutler_project::Project;
use gitbutler_reference::{LocalRefname, Refname};
use gitbutler_stack::{Stack, VirtualBranchesHandle};

use crate::command::debug_print;

pub fn list_commit_files(project: Project, commit_id_hex: String) -> Result<()> {
let commit_id = gix::ObjectId::from_hex(commit_id_hex.as_bytes())?;
debug_print(gitbutler_branch_actions::list_commit_files(
&project,
commit_id.to_git2(),
)?)
}

pub fn set_base(project: Project, short_tracking_branch_name: String) -> Result<()> {
let branch_name = format!("refs/remotes/{}", short_tracking_branch_name)
.parse()
Expand Down
3 changes: 3 additions & 0 deletions crates/gitbutler-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ fn main() -> Result<()> {
args::Subcommands::Branch(vbranch::Platform { cmd }) => {
let project = command::prepare::project_from_path(args.current_dir)?;
match cmd {
Some(vbranch::SubCommands::ListCommitFiles { commit_id }) => {
command::vbranch::list_commit_files(project, commit_id)
}
Some(vbranch::SubCommands::SetBase {
short_tracking_branch_name,
}) => command::vbranch::set_base(project, short_tracking_branch_name),
Expand Down

0 comments on commit 93b838c

Please sign in to comment.