Skip to content

Commit

Permalink
feat(cli): show repo and current tag name in "cog log"
Browse files Browse the repository at this point in the history
  • Loading branch information
renaultfernandes committed Oct 10, 2020
1 parent 64c0afd commit 7c6c725
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bin/cog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,14 @@ fn main() -> Result<()> {
LOG => {
let cocogitto = CocoGitto::get()?;

let repo_tag_name = match cocogitto.get_repo_tag_name() {
Some(name) => name,
None => "cog log".to_string(),
};

let mut output = Output::builder()
.with_pager_from_env("PAGER")
// TODO: replace with "repo_name:latest_tag"?
.with_file_name("cog log")
.with_file_name(repo_tag_name)
.build()?;

let subcommand = matches.subcommand_matches(LOG).unwrap();
Expand Down
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,20 @@ impl CocoGitto {
self.repository.get_author()
}

pub fn get_repo_tag_name(&self) -> Option<String> {
let mut repo_tag_name = String::new();

let repo_path = self.repository.get_repo_dir()?.iter().last()?;
repo_tag_name.push_str(repo_path.to_str()?);

if let Ok(latest_tag) = self.repository.get_latest_tag() {
repo_tag_name.push_str(":");
repo_tag_name.push_str(&latest_tag);
};

Some(repo_tag_name)
}

pub fn check_and_edit(&self) -> Result<()> {
let from = self.repository.get_first_commit()?;
let head = self.repository.get_head_commit()?;
Expand Down

0 comments on commit 7c6c725

Please sign in to comment.