fix: Change commit from 'latest' to 'current'

pull/1/head
sgoudham 2 years ago
parent b1112bbddc
commit af001e002a
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 76 KiB

@ -1,6 +1,6 @@
use std::panic::set_hook;
use clap::{command, crate_authors, crate_description, crate_version, Arg, Command, ErrorKind};
use clap::{command, crate_authors, crate_version, Arg, Command, ErrorKind};
use git_view::Git;
use git_view::GitView;
@ -44,11 +44,11 @@ This currently supports the following URLs:
)
.arg(
Arg::new("commit")
.long_help("The commit to view git repository on\n[default: latest]")
.long_help("The commit to view git repository on\n[default: current commit]")
.short('c')
.long("commit")
.value_name("hash")
.default_missing_value("latest")
.default_missing_value("current")
.conflicts_with_all(&["remote", "branch"])
.display_order(3),
)

@ -225,7 +225,7 @@ impl<'a> GitView<'a> {
// Handle commit flag
if let Some(commit) = self.commit {
if commit == "latest" {
if commit == "current" {
let commit_hash = match git.get_current_commit()? {
GitOutput::Ok(hash) => Ok(hash),
GitOutput::Err(err) => Err(AppError::new(ErrorType::CommandFailed, err)),
@ -770,7 +770,7 @@ mod lib_tests {
#[test]
fn is_latest_commit() {
let handler = GitView::builder().with_commit("latest").build();
let handler = GitView::builder().with_commit("current").build();
let url = Url::new("https", Domain::GitHub, "sgoudham/git-view");
let expected_final_url = "https://github.com/sgoudham/git-view/tree/commit_hash";
let mut mock = MockGitTrait::default();

Loading…
Cancel
Save