Skip to content
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
1,204 changes: 776 additions & 428 deletions Cargo.lock

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,38 +123,38 @@ pre-release-replacements = [

[dependencies]
git2 = { version = "0.20", default-features = false, features = ["vendored-libgit2"] }
git-config-env = "0.2.1"
clap = { version = "4.5.4", features = ["derive"] }
clap-verbosity-flag = "3.0.0"
log = "0.4.21"
git-config-env = "1.0.0"
clap = { version = "4.5.60", features = ["derive"] }
clap-verbosity-flag = "3.0.4"
log = "0.4.29"
env_logger = { version = "0.11", default-features = false, features = ["humantime", "color"] }
colorchoice-clap = "1.0.3"
anstyle = "1.0.6"
anstream = "0.6.13"
proc-exit = "2.0.1"
colorchoice-clap = "1.0.7"
anstyle = "1.0.13"
anstream = "1.0.0"
proc-exit = "2.0.2"
eyre = "0.6.12"
human-panic = "2.0.0"
termtree = "0.5.0"
indexmap = "2.2.6"
human-panic = "2.0.5"
termtree = "1.0.0"
indexmap = "2.13.0"

git2-ext = "0.6.3"
git2-ext = "1.0.0"
git-branch-stash = "0.10.2"
humantime = "2.1.0"
humantime = "2.3.0"
itertools = "0.14.0"
ignore = "0.4.22"
bstr = "1.9.1"
ignore = "0.4.25"
bstr = "1.12.1"
maplit = "1.0.2"
petgraph = "0.8.0"
downcast-rs = "2.0.0"
petgraph = "0.8.3"
downcast-rs = "2.0.2"
names = { version = "0.14.0", default-features = false }
elsa = "1.10.0"
elsa = "1.11.2"
shlex = "1.3.0"

[dev-dependencies]
git-fixture = { version = "0.3.4", features = ["yaml"] }
assert_fs = "1.1.1"
snapbox = { version = "0.6.0", features = ["cmd", "dir"] }
automod = "1.0.14"
git-fixture = { version = "1.0.0", features = ["yaml"] }
assert_fs = "1.1.3"
snapbox = { version = "1.0.0", features = ["cmd", "dir"] }
automod = "1.0.16"

[lints]
workspace = true
12 changes: 6 additions & 6 deletions src/bin/git-stack/amend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ impl AmendArgs {
let results = executor.run(&mut repo, &script);
for (err, name, dependents) in results.iter() {
success = false;
log::error!("Failed to re-stack branch `{}`: {}", name, err);
log::error!("Failed to re-stack branch `{name}`: {err}");
if !dependents.is_empty() {
log::error!(" Blocked dependents: {}", dependents.iter().join(", "));
}
Expand Down Expand Up @@ -379,7 +379,7 @@ fn commit_fixup(
&[&parent_raw_commit],
None,
)?;
log::debug!("committed {} {}", id, message);
log::debug!("committed {id} {message}");
id
};
if !dry_run {
Expand All @@ -398,24 +398,24 @@ fn commit_fixup(
}
}
if let Some(head_branch) = head_branch {
log::debug!("switching to {} {}", head_branch, id);
log::debug!("switching to {head_branch} {id}");
repo.switch_branch(
head_branch
.local_name()
.expect("HEAD branch is always local"),
)?;
} else {
log::debug!("switching to {}", id);
log::debug!("switching to {id}");
repo.switch_commit(id)?;
}

if let Some(stash_id) = stash_id {
match repo.stash_pop(stash_id) {
Ok(()) => {
log::debug!("Dropped refs/stash {}", stash_id);
log::debug!("Dropped refs/stash {stash_id}");
}
Err(err) => {
log::error!("Failed to pop {} from stash: {}", stash_id, err);
log::error!("Failed to pop {stash_id} from stash: {err}");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/bin/git-stack/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub(crate) fn protected(args: &crate::args::Args) -> proc_exit::ExitResult {
let mut protected_branches = git_stack::legacy::git::Branches::new([]);
for branch in repo.local_branches() {
if protected.is_protected(&branch.name) {
log::trace!("Branch {} is protected", branch);
log::trace!("Branch {branch} is protected");
protected_branches.insert(branch.clone());
if let Some(remote) = repo.find_remote_branch(repo.pull_remote(), &branch.name) {
protected_branches.insert(remote.clone());
Expand All @@ -82,7 +82,7 @@ pub(crate) fn protected(args: &crate::args::Args) -> proc_exit::ExitResult {
}
} else {
for branch in branches {
log::debug!("Unprotected: {}", branch);
log::debug!("Unprotected: {branch}");
}
}
}
Expand Down
8 changes: 3 additions & 5 deletions src/bin/git-stack/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ pub(crate) fn resolve_implicit_base(
None => {
let assumed_base_oid = git_stack::graph::infer_base(repo, head_oid).unwrap_or(head_oid);
log::warn!(
"Could not find protected branch for {}, assuming {}",
head_oid,
assumed_base_oid
"Could not find protected branch for {head_oid}, assuming {assumed_base_oid}"
);
AnnotatedOid::new(assumed_base_oid)
}
Expand Down Expand Up @@ -203,7 +201,7 @@ pub(crate) fn git_prune_development(
for branch in branches {
if !remote_branches.contains(branch) {
let remote_branch = format!("{remote}/{branch}");
log::info!("Pruning {}", remote_branch);
log::info!("Pruning {remote_branch}");
if !dry_run {
let mut branch = repo
.raw()
Expand All @@ -217,7 +215,7 @@ pub(crate) fn git_prune_development(
}

pub(crate) fn git_fetch_upstream(remote: &str, branch_name: &str) -> eyre::Result<()> {
log::debug!("git fetch {} {}", remote, branch_name);
log::debug!("git fetch {remote} {branch_name}");
// A little uncertain about some of the weirder authentication needs, just deferring to `git`
// instead of using `libgit2`
let status = std::process::Command::new("git")
Expand Down
2 changes: 1 addition & 1 deletion src/bin/git-stack/reword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl RewordArgs {
let results = executor.run(&mut repo, &script);
for (err, name, dependents) in results.iter() {
success = false;
log::error!("Failed to re-stack branch `{}`: {}", name, err);
log::error!("Failed to re-stack branch `{name}`: {err}");
if !dependents.is_empty() {
log::error!(" Blocked dependents: {}", dependents.iter().join(", "));
}
Expand Down
24 changes: 11 additions & 13 deletions src/bin/git-stack/stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl State {
let mut protected_branches = git_stack::legacy::git::Branches::new([]);
for branch in repo.local_branches() {
if protected.is_protected(&branch.name) {
log::trace!("Branch {} is protected", branch);
log::trace!("Branch {branch} is protected");
if let Some(remote) = repo.find_remote_branch(repo.pull_remote(), &branch.name) {
protected_branches.insert(remote.clone());
branches.insert(remote);
Expand Down Expand Up @@ -341,11 +341,11 @@ pub(crate) fn stack(args: &crate::args::Args) -> proc_exit::ExitResult {
match git_fetch_upstream(remote, branch.name.as_str()) {
Ok(_) => (),
Err(err) => {
log::warn!("Skipping pull of `{}`, {}", branch, err);
log::warn!("Skipping pull of `{branch}`, {err}");
}
}
} else {
log::warn!("Skipping pull of `{}` local branch", branch);
log::warn!("Skipping pull of `{branch}` local branch");
}
}
}
Expand All @@ -362,7 +362,7 @@ pub(crate) fn stack(args: &crate::args::Args) -> proc_exit::ExitResult {
if state.repo.is_dirty() {
let message = "Working tree is dirty, aborting";
if state.dry_run {
log::error!("{}", message);
log::error!("{message}");
} else {
git_stack::legacy::git::stash_pop(&mut state.repo, stash_id);
return Err(proc_exit::sysexits::USAGE_ERR.with_message(message));
Expand Down Expand Up @@ -419,7 +419,7 @@ pub(crate) fn stack(args: &crate::args::Args) -> proc_exit::ExitResult {
let results = executor.run_script(&mut state.repo, &script);
for (err, name, dependents) in results.iter() {
success = false;
log::error!("Failed to re-stack branch `{}`: {}", name, err);
log::error!("Failed to re-stack branch `{name}`: {err}");
if !dependents.is_empty() {
log::error!(" Blocked dependents: {}", dependents.iter().join(", "));
}
Expand Down Expand Up @@ -909,9 +909,7 @@ fn resolve_implicit_base(
let assumed_base_oid =
git_stack::legacy::git::infer_base(repo, head_oid).unwrap_or(head_oid);
log::warn!(
"Could not find protected branch for {}, assuming {}",
head_oid,
assumed_base_oid
"Could not find protected branch for {head_oid}, assuming {assumed_base_oid}"
);
AnnotatedOid::new(assumed_base_oid)
}
Expand Down Expand Up @@ -977,7 +975,7 @@ fn git_prune_development(
for branch in branches {
if !remote_branches.contains(branch) {
let remote_branch = format!("{remote}/{branch}");
log::info!("Pruning {}", remote_branch);
log::info!("Pruning {remote_branch}");
if !dry_run {
let mut branch = repo
.raw()
Expand All @@ -991,7 +989,7 @@ fn git_prune_development(
}

fn git_fetch_upstream(remote: &str, branch_name: &str) -> eyre::Result<()> {
log::debug!("git fetch {} {}", remote, branch_name);
log::debug!("git fetch {remote} {branch_name}");
// A little uncertain about some of the weirder authentication needs, just deferring to `git`
// instead of using `libgit2`
let status = std::process::Command::new("git")
Expand Down Expand Up @@ -1070,15 +1068,15 @@ fn git_push_node(
}
}
Err(err) => {
log::debug!("`git push` failed with {}", err);
log::debug!("`git push` failed with {err}");
failed.push(local_branch.to_owned());
}
}
}
} else if node.action.is_protected() {
log::debug!("Skipping push of `{}`, protected", branch);
log::debug!("Skipping push of `{branch}`, protected");
} else {
log::debug!("Skipping push of `{}`", branch);
log::debug!("Skipping push of `{branch}`");
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/bin/git-stack/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl SyncArgs {
match crate::ops::git_fetch_upstream(remote, branch.name.as_str()) {
Ok(_) => update_branches = true,
Err(err) => {
log::warn!("Skipping pull of `{}`, {}", branch, err);
log::warn!("Skipping pull of `{branch}`, {err}");
}
}
}
Expand Down Expand Up @@ -168,7 +168,7 @@ impl SyncArgs {
let results = executor.run(&mut repo, &script);
for (err, name, dependents) in results.iter() {
success = false;
log::error!("Failed to re-stack branch `{}`: {}", name, err);
log::error!("Failed to re-stack branch `{name}`: {err}");
if !dependents.is_empty() {
log::error!(" Blocked dependents: {}", dependents.iter().join(", "));
}
Expand Down Expand Up @@ -206,7 +206,7 @@ fn plan_changes(
protect_commit_count: Option<usize>,
protect_commit_time: std::time::SystemTime,
) -> eyre::Result<Vec<git_stack::rewrite::Script>> {
log::trace!("Planning stack changes with base={}, onto={}", base, onto);
log::trace!("Planning stack changes with base={base}, onto={onto}");
let graphed_branches = branches.clone();
let mut graph = git_stack::graph::Graph::from_branches(repo, graphed_branches)?;
git_stack::graph::protect_branches(&mut graph);
Expand Down
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl RepoConfig {
let default_config = match git2::Config::open_default() {
Ok(config) => Some(config),
Err(err) => {
log::debug!("Failed to load git config: {}", err);
log::debug!("Failed to load git config: {err}");
None
}
};
Expand All @@ -75,7 +75,7 @@ impl RepoConfig {
match git2::Config::open(&config_path) {
Ok(config) => Ok(Self::from_gitconfig(&config)),
Err(err) => {
log::debug!("Failed to load git config: {}", err);
log::debug!("Failed to load git config: {err}");
Ok(Default::default())
}
}
Expand All @@ -94,7 +94,7 @@ impl RepoConfig {
match git2::Config::open(&config_path) {
Ok(config) => Ok(Self::from_gitconfig(&config)),
Err(err) => {
log::debug!("Failed to load git config: {}", err);
log::debug!("Failed to load git config: {err}");
Ok(Default::default())
}
}
Expand Down Expand Up @@ -125,7 +125,7 @@ impl RepoConfig {
let mut config = Self::default();

for (key, value) in iter {
log::trace!("Env config: {}={:?}", key, value);
log::trace!("Env config: {key}={value:?}");
if key == CORE_EDITOR {
if let Some(value) = value {
config.editor = Some(value.into_owned());
Expand Down Expand Up @@ -199,7 +199,7 @@ impl RepoConfig {
let config = match git2::Config::open_default() {
Ok(config) => Some(config),
Err(err) => {
log::debug!("Failed to load git config: {}", err);
log::debug!("Failed to load git config: {err}");
None
}
};
Expand Down
12 changes: 4 additions & 8 deletions src/git/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,15 +1195,11 @@ pub fn stash_push(repo: &mut dyn Repo, context: &str) -> Option<git2::Oid> {
);
match repo.stash_push(Some(&stash_msg)) {
Ok(stash_id) => {
log::info!(
"Saved working directory and index state {}: {}",
stash_msg,
stash_id
);
log::info!("Saved working directory and index state {stash_msg}: {stash_id}");
Some(stash_id)
}
Err(err) => {
log::debug!("Failed to stash: {}", err);
log::debug!("Failed to stash: {err}");
None
}
}
Expand All @@ -1213,10 +1209,10 @@ pub fn stash_pop(repo: &mut dyn Repo, stash_id: Option<git2::Oid>) {
if let Some(stash_id) = stash_id {
match repo.stash_pop(stash_id) {
Ok(()) => {
log::info!("Dropped refs/stash {}", stash_id);
log::info!("Dropped refs/stash {stash_id}");
}
Err(err) => {
log::error!("Failed to pop {} from stash: {}", stash_id, err);
log::error!("Failed to pop {stash_id} from stash: {err}");
}
}
}
Expand Down
Loading
Loading