build: Update 'git-browser' to 'git-view'

pull/6/head
sgoudham 2 years ago
parent f151f58b34
commit 5f0f2fff54
Signed by: hammy
GPG Key ID: 44E818FD5457EEA4

@ -1,20 +1,20 @@
[package] [package]
name = "git-browser" name = "git-view"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
authors = ["Goudham Suresh <sgoudham@gmail.com>"] authors = ["Goudham Suresh <sgoudham@gmail.com>"]
description = "A git sub-command to open your git repository in the web browser" description = "A git sub-command to view your git repository in the web browser"
license = "MIT" license = "MIT"
readme = "README.md" readme = "README.md"
repository = "https://github.com/sgoudham/git-browser" repository = "https://github.com/sgoudham/git-view"
exclude = [".github/**"] exclude = [".github/**"]
[[bin]] [[bin]]
name = "git-browser" name = "git-view"
path = "src/bin/git-browser.rs" path = "src/bin/git-view.rs"
[lib] [lib]
name = "git_browser" name = "git_view"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]

@ -1,7 +1,7 @@
use std::panic::set_hook; use std::panic::set_hook;
use clap::{command, crate_authors, crate_description, crate_version, Arg, Command, ErrorKind}; use clap::{command, crate_authors, crate_description, crate_version, Arg, Command, ErrorKind};
use git_browser::GitUpstream; use git_view::GitView;
macro_rules! clap_panic { macro_rules! clap_panic {
($e:expr) => { ($e:expr) => {
@ -12,15 +12,15 @@ macro_rules! clap_panic {
fn main() { fn main() {
set_hook(Box::new(|info| clap_panic!(info))); set_hook(Box::new(|info| clap_panic!(info)));
let matches = Command::new("git-upstream") let matches = Command::new("git-view")
.version(crate_version!()) .version(crate_version!())
.author(crate_authors!()) .author(crate_authors!())
.about(crate_description!()) .about(crate_description!())
.long_about(None) .long_about(None)
.arg(Arg::new("branch").help("The branch to open Github repo on")) .arg(Arg::new("branch").help("The branch to view git repository on"))
.arg( .arg(
Arg::new("remote") Arg::new("remote")
.help("The remote to open Github repo on") .help("The remote to view git repository on")
.short('r') .short('r')
.long("remote") .long("remote")
.default_value("origin"), .default_value("origin"),
@ -40,14 +40,14 @@ fn main() {
); );
let matches = matches.get_matches(); let matches = matches.get_matches();
let mut git_upstream = GitUpstream::new( let mut git_view = GitView::new(
matches.value_of("branch").map(str::to_string), matches.value_of("branch").map(str::to_string),
matches.value_of("remote").unwrap().to_string(), matches.value_of("remote").unwrap().to_string(),
matches.is_present("commit"), matches.is_present("commit"),
matches.is_present("print"), matches.is_present("print"),
); );
if let Err(err) = git_upstream.open_upstream_repository() { if let Err(err) = git_view.open_upstream_repository() {
clap_panic!(err); clap_panic!(err);
} }
} }

@ -1,13 +1,13 @@
use std::process::Command; use std::process::Command;
pub struct GitUpstream { pub struct GitView {
remote: String, remote: String,
branch: Option<String>, branch: Option<String>,
is_commit: bool, is_commit: bool,
is_print: bool, is_print: bool,
} }
impl GitUpstream { impl GitView {
pub fn new(branch: Option<String>, remote: String, is_commit: bool, is_print: bool) -> Self { pub fn new(branch: Option<String>, remote: String, is_commit: bool, is_print: bool) -> Self {
Self { Self {
remote, remote,
@ -23,6 +23,7 @@ impl GitUpstream {
// Retrieve the current branch // Retrieve the current branch
self.populate_branch()?; self.populate_branch()?;
let git_url = Command::new("git") let git_url = Command::new("git")
.args(["ls-remote", "--get-url", &self.remote]) .args(["ls-remote", "--get-url", &self.remote])
.output() .output()

Loading…
Cancel
Save