-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from TomasTomecek/bump-clap-git2
update clap to 4 and git2 to 0.14
- Loading branch information
Showing
7 changed files
with
92 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,9 @@ Cargo.lock | |
|
||
.cmake/ | ||
.cargo/ | ||
|
||
pretty-git-prompt-*.crate | ||
|
||
# RPM building | ||
SRPMS/ | ||
x86_64/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
--- | ||
downstream_package_name: rust-pretty-git-prompt | ||
srpm_build_deps: | ||
- cargo | ||
- rust | ||
actions: | ||
create-archive: | ||
- cargo publish --dry-run --allow-dirty | ||
- bash -c "ls -1 target/package/*.crate" | ||
jobs: | ||
- job: copr_build | ||
trigger: pull_request | ||
targets: | ||
- fedora-all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ name = "pretty-git-prompt" | |
version = "0.2.1" | ||
authors = ["Tomas Tomecek <[email protected]>"] | ||
description = "Your current git repository information inside a beautiful shell prompt." | ||
license-file = "LICENSE" | ||
license = "MIT" | ||
documentation = "https://github.com/TomasTomecek/pretty-git-prompt/blob/master/README.md" | ||
homepage = "https://github.com/TomasTomecek/pretty-git-prompt" | ||
repository = "https://github.com/TomasTomecek/pretty-git-prompt" | ||
|
@@ -14,14 +14,14 @@ path = "src/main.rs" | |
name = "pretty-git-prompt" | ||
|
||
[dependencies] | ||
yaml-rust = "0.4.2" | ||
yaml-rust = "0.4.5" | ||
|
||
[dependencies.clap] | ||
version = "3.0" | ||
version = "4.*" | ||
default-features = false | ||
features = ["std"] | ||
features = ["std", "cargo"] | ||
|
||
[dependencies.git2] | ||
version = "0.13" | ||
version = "0.14.*" | ||
default-features = false | ||
features = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,36 +5,44 @@ | |
|
||
Name: rust-%{crate} | ||
Version: 0.2.1 | ||
Release: 1%{?dist} | ||
Release: %autorelease | ||
Summary: Your current git repository information inside a beautiful shell prompt | ||
|
||
License: MIT | ||
URL: https://crates.io/crates/pretty-git-prompt | ||
Source0: https://crates.io/api/v1/crates/%{crate}/%{version}/download#/%{crate}-%{version}.crate | ||
Source0: %{crates_source} | ||
|
||
ExclusiveArch: %{rust_arches} | ||
|
||
BuildRequires: rust-packaging | ||
# [dependencies] | ||
BuildRequires: (crate(clap) >= 2.19.0 with crate(clap) < 3.0.0) | ||
BuildRequires: (crate(git2) >= 0.7.0 with crate(git2) < 0.8.0) | ||
BuildRequires: (crate(yaml-rust) >= 0.3.4 with crate(yaml-rust) < 0.4.0) | ||
BuildRequires: rust-packaging >= 23 | ||
|
||
%description | ||
%{summary}. | ||
|
||
%package -n %{crate} | ||
Summary: %{summary} | ||
# MIT | ||
# MIT AND GPL-2.0-only WITH GCC-exception-2.0 AND BSD-3-Clause | ||
# MIT OR Apache-2.0 | ||
# MIT OR Apache-2.0 OR Zlib | ||
# Zlib OR Apache-2.0 OR MIT | ||
License: MIT AND BSD-3-Clause AND GPL-2.0-only WITH GCC-exception-2.0 AND (MIT OR Apache-2.0) AND (MIT OR Apache-2.0 OR Zlib) | ||
# LICENSE.dependencies contains a full license breakdown | ||
|
||
%description -n %{crate} | ||
%{summary}. | ||
|
||
%prep | ||
%autosetup -n %{crate}-%{version} -p1 | ||
%autosetup -n %{crate}-%{version_no_tilde} -p1 | ||
%cargo_prep | ||
|
||
%generate_buildrequires | ||
%cargo_generate_buildrequires | ||
|
||
%build | ||
%cargo_build | ||
%cargo_license_summary | ||
%{cargo_license} > LICENSE.dependencies | ||
|
||
%install | ||
%cargo_install | ||
|
@@ -47,31 +55,10 @@ Summary: %{summary} | |
|
||
%files -n %{crate} | ||
%license LICENSE | ||
%license LICENSE.dependencies | ||
%doc README.md | ||
%doc files | ||
%{_bindir}/pretty-git-prompt | ||
|
||
%changelog | ||
* Mon Apr 06 2020 Tomas Tomecek <[email protected]> - 0.2.1-1 | ||
- new upstream release: 0.2.1 | ||
|
||
* Sat Feb 02 2019 Fedora Release Engineering <[email protected]> - 0.2.0-7 | ||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild | ||
|
||
* Fri Aug 10 2018 Josh Stone <[email protected]> - 0.2.0-6 | ||
- Rebuild with fixed rust-libgit2-sys-0.7.7 | ||
|
||
* Fri Aug 10 2018 Igor Gnatenko <[email protected]> - 0.2.0-5 | ||
- Rebuild for libgit2 0.27.x | ||
|
||
* Sat Jul 14 2018 Fedora Release Engineering <[email protected]> - 0.2.0-4 | ||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild | ||
|
||
* Mon Mar 12 2018 Igor Gnatenko <[email protected]> - 0.2.0-3 | ||
- Bump git2 to 0.7 | ||
|
||
* Fri Feb 09 2018 Fedora Release Engineering <[email protected]> - 0.2.0-2 | ||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild | ||
|
||
* Sun Jan 28 2018 Igor Gnatenko <[email protected]> - 0.2.0-1 | ||
- Initial package | ||
%autochangelog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ use constants::*; | |
use models::{DisplayMaster}; | ||
|
||
use git2::Repository; | ||
use clap::{App,Arg}; | ||
use clap::{Arg, ArgAction, Command}; | ||
|
||
// util mod def needs to be first b/c of macro definitions and usage in other modules | ||
#[macro_use] | ||
|
@@ -23,97 +23,67 @@ mod conf; | |
mod constants; | ||
mod models; | ||
|
||
|
||
fn get_version_str() -> String { | ||
let version: Option<&'static str> = option_env!("CARGO_PKG_VERSION"); | ||
let commit: Option<&'static str> = option_env!("TRAVIS_COMMIT"); | ||
let is_dirty: Option<&'static str> = option_env!("GIT_REPO_IS_DIRTY"); | ||
format!( | ||
"{} ({}{})", | ||
match version { | ||
Some(v) => v, | ||
None => "<version undefined>", | ||
}, | ||
match commit { | ||
Some(v) => v, | ||
None => "<commit unknown>" | ||
}, | ||
match is_dirty { | ||
Some(_) => ", dirty", | ||
None => "" | ||
} | ||
) | ||
} | ||
|
||
fn run_app() -> Result<(), String> { | ||
let version = get_version_str(); | ||
let version_ref: &str = version.as_str(); | ||
let def_conf_desc: &str = &format!("Create default config at \"{}\".", get_default_config_path().to_str().unwrap()); | ||
let app = App::new("pretty-git-prompt") | ||
.version(version_ref) | ||
fn main() { | ||
let def_conf_desc: String = format!("Create default config at \"{}\".", get_default_config_path().to_str().unwrap()); | ||
let matches = Command::new("pretty-git-prompt") | ||
.version(option_env!("CARGO_PKG_VERSION")) | ||
.author("Tomas Tomecek <[email protected]>") | ||
.about("Get `git status` inside your shell prompt.") | ||
.subcommand(App::new(CLI_DEFAULT_CONFIG_SUBC_NAME) | ||
.about(def_conf_desc)) | ||
.subcommand(Command::new("create-default-config") | ||
.about(def_conf_desc)) | ||
.arg(Arg::new("config") | ||
.short('c') | ||
.long("config") | ||
.value_name("FILE") | ||
.help("Use the given config file.") | ||
.takes_value(true)) | ||
.short('c') | ||
.long("config") | ||
.value_name("FILE") | ||
.help("Use the given config file.")) | ||
.arg(Arg::new("debug") | ||
.short('d') | ||
.long("debug") | ||
.help("Print debug messages, useful for identifying issues.")); | ||
let matches = app.get_matches(); | ||
.short('d') | ||
.long("debug") | ||
.help("Print debug messages, useful for identifying issues.") | ||
.action(ArgAction::SetTrue) | ||
).get_matches(); | ||
|
||
let debug_enabled = matches.is_present("debug"); | ||
let debug_enabled = matches.get_flag("debug"); | ||
if debug_enabled { println!("Debug messages are enabled."); } | ||
|
||
let conf_path: Option<String> = if matches.is_present("config") { | ||
Some(String::from(matches.value_of("config").unwrap())) | ||
} else { | ||
None | ||
}; | ||
|
||
// create default config command | ||
if matches.is_present(CLI_DEFAULT_CONFIG_SUBC_NAME) { | ||
let p = get_default_config_path(); | ||
match create_default_config(&p) { | ||
Ok(path) => { | ||
println!("Configuration file created at \"{}\"", path); | ||
return Ok(()); | ||
} | ||
Err(e) => { | ||
return Err(format!("Failed to create configuration file \"{}\": {}", p.to_str().unwrap(), e)); | ||
} | ||
}; | ||
} else { | ||
// no command, run primary functionality | ||
let repo = match Repository::discover(".") { | ||
Ok(repo) => repo, | ||
// not a git repository, ignore | ||
Err(e) => { | ||
if debug_enabled { println!("This is not a git repository: {:?}", e); } | ||
return Ok(()); | ||
} | ||
}; | ||
|
||
let backend = Backend::new(repo, debug_enabled); | ||
let dm: DisplayMaster = DisplayMaster::new(backend, debug_enabled); | ||
let mut conf: Conf = get_configuration(conf_path, dm); | ||
let out: String = conf.populate_values(); | ||
println!("{}", out); | ||
} | ||
Ok(()) | ||
} | ||
match matches.subcommand() { | ||
Some(("create-default-config", _sub_matches)) => { | ||
let p = get_default_config_path(); | ||
match create_default_config(&p) { | ||
Ok(path) => { | ||
println!("Configuration file created at \"{}\"", path); | ||
::std::process::exit(0); | ||
} | ||
Err(e) => { | ||
if let Err(e2) = writeln!( | ||
io::stderr(), | ||
"Failed to create configuration file \"{}\": {}", | ||
p.to_str().unwrap(), | ||
e | ||
) { | ||
println!("Writing error: {}", e2.to_string()); | ||
} | ||
::std::process::exit(2); | ||
} | ||
}; | ||
}, | ||
_ => { | ||
// no command, run primary functionality | ||
let repo = match Repository::discover(".") { | ||
Ok(repo) => repo, | ||
// not a git repository, ignore | ||
Err(e) => { | ||
if debug_enabled { println!("This is not a git repository: {:?}", e); } | ||
::std::process::exit(0); | ||
} | ||
}; | ||
|
||
fn main() { | ||
::std::process::exit(match run_app() { | ||
Ok(_) => 0, | ||
Err(err) => { | ||
writeln!(io::stderr(), "{}", err).unwrap(); | ||
2 | ||
let backend = Backend::new(repo, debug_enabled); | ||
let dm: DisplayMaster = DisplayMaster::new(backend, debug_enabled); | ||
let conf_path = matches.get_one::<String>("config"); | ||
let mut conf: Conf = get_configuration(conf_path.cloned(), dm); | ||
let out: String = conf.populate_values(); | ||
println!("{}", out); | ||
} | ||
}); | ||
} | ||
} |