Skip to content

Commit d88f75d

Browse files
committed
Restore --reverse flag with deprecation warning
1 parent a565e2b commit d88f75d

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

git-branchless-opts/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ pub struct SmartlogArgs {
340340
#[clap(value_parser)]
341341
pub revset: Option<Revset>,
342342

343+
/// (Deprecated)
344+
/// Print the smartlog in the opposite of the usual order, with the latest
345+
/// commits first. Can be configured via `branchless.smartlog.reverse`.
346+
#[clap(long)]
347+
pub reverse: bool,
348+
343349
/// Don't automatically add HEAD and the main branch to the list of commits
344350
/// to present. They will still be added if included in the revset.
345351
#[clap(long)]

git-branchless-smartlog/src/lib.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,11 @@ mod render {
747747
/// The options to use when resolving the revset.
748748
pub resolve_revset_options: ResolveRevsetOptions,
749749

750+
/// Deprecated
751+
/// Reverse the ordering of items in the smartlog output, list the most
752+
/// recent commits first.
753+
pub reverse: bool,
754+
750755
/// Normally HEAD and the main branch are included. Set this to exclude them.
751756
pub exact: bool,
752757
}
@@ -763,6 +768,7 @@ pub fn smartlog(
763768
event_id,
764769
revset,
765770
resolve_revset_options,
771+
reverse,
766772
exact,
767773
} = options;
768774

@@ -820,9 +826,22 @@ pub fn smartlog(
820826
exact,
821827
)?;
822828

823-
let reverse = get_smartlog_reverse(&repo)?;
829+
if reverse {
830+
print!(
831+
"\
832+
branchless: WARNING: The `--reverse` flag is deprecated.
833+
branchless: Please use the `branchless.smartlog.reverse` configuration option.
834+
"
835+
);
836+
}
837+
let reverse_cfg = get_smartlog_reverse(&repo)?;
838+
let reverse_value = match (reverse_cfg, reverse) {
839+
(.., true) => true,
840+
_ => reverse_cfg,
841+
};
842+
824843
let mut lines = render_graph(
825-
&effects.reverse_order(reverse),
844+
&effects.reverse_order(reverse_value),
826845
&repo,
827846
&dag,
828847
&graph,
@@ -845,7 +864,7 @@ pub fn smartlog(
845864
],
846865
)?
847866
.into_iter();
848-
while let Some(line) = if reverse {
867+
while let Some(line) = if reverse_value {
849868
lines.next_back()
850869
} else {
851870
lines.next()
@@ -910,6 +929,7 @@ pub fn command_main(ctx: CommandContext, args: SmartlogArgs) -> EyreExitOr<()> {
910929
event_id,
911930
revset,
912931
resolve_revset_options,
932+
reverse,
913933
exact,
914934
} = args;
915935

@@ -920,6 +940,7 @@ pub fn command_main(ctx: CommandContext, args: SmartlogArgs) -> EyreExitOr<()> {
920940
event_id,
921941
revset,
922942
resolve_revset_options,
943+
reverse,
923944
exact,
924945
},
925946
)

git-branchless/tests/test_init.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,9 @@ fn test_main_branch_not_found_error_message() -> eyre::Result<()> {
316316
317317
0: branchless::core::eventlog::from_event_log_db with effects=<Output fancy=false> repo=<Git repository at: "<repo-path>/.git/"> event_log_db=<EventLogDb path=Some("<repo-path>/.git/branchless/db.sqlite3")>
318318
at some/file/path.rs:123
319-
1: git_branchless_smartlog::smartlog with effects=<Output fancy=false> git_run_info=<GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> options=SmartlogOptions { event_id: None, revset: None, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false }, exact: false }
319+
1: git_branchless_smartlog::smartlog with effects=<Output fancy=false> git_run_info=<GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> options=SmartlogOptions { event_id: None, revset: None, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false }, reverse: false, exact: false }
320320
at some/file/path.rs:123
321-
2: git_branchless_smartlog::command_main with ctx=CommandContext { effects: <Output fancy=false>, git_run_info: <GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> } args=SmartlogArgs { event_id: None, revset: None, exact: false, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false } }
321+
2: git_branchless_smartlog::command_main with ctx=CommandContext { effects: <Output fancy=false>, git_run_info: <GitRunInfo path_to_git="<git-executable>" working_directory="<repo-path>" env=not shown> } args=SmartlogArgs { event_id: None, revset: None, reverse: false, exact: false, resolve_revset_options: ResolveRevsetOptions { show_hidden_commits: false } }
322322
at some/file/path.rs:123
323323
324324
Suggestion:

0 commit comments

Comments
 (0)