mirror of
https://github.com/starship/starship.git
synced 2026-06-23 02:05:51 +07:00
build: Add additional build information to version and bug report (#2124)
* fix https://github.com/starship/starship/issues * cargo fmt * upgrade shadow-rs 0.5.6 * upgrade shadow-rs * update * complet bug_report infomation * cargo fmt * upgrade shadow-rs 0.5.11 * upgrade shadow-rs 0.5.14 * fixed:https://github.com/starship/starship/pull/2124#discussion_r559076634 fixed:https://github.com/starship/starship/pull/2124#discussion_r559076918 * add long_version * upgrade shadow-rs 0.5.19; adaptate clap version() use by shadow-rs clap_version() * fix unit test error * fix test error * upgrade shadow-rs 0.5.22 * upgrade shadow-rs 0.5.23
This commit is contained in:
+25
-8
@@ -1,6 +1,6 @@
|
||||
use crate::shadow;
|
||||
use crate::utils::exec_cmd;
|
||||
|
||||
use clap::crate_version;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -8,6 +8,7 @@ use std::path::PathBuf;
|
||||
const GIT_IO_BASE_URL: &str = "https://git.io/";
|
||||
|
||||
pub fn create() {
|
||||
println!("{}\n", shadow::version().trim());
|
||||
let os_info = os_info::get();
|
||||
|
||||
let environment = Environment {
|
||||
@@ -18,7 +19,7 @@ pub fn create() {
|
||||
starship_config: get_starship_config(),
|
||||
};
|
||||
|
||||
let link = make_github_issue_link(crate_version!(), environment);
|
||||
let link = make_github_issue_link(environment);
|
||||
let short_link = shorten_link(&link);
|
||||
|
||||
if open::that(&link)
|
||||
@@ -63,7 +64,14 @@ struct Environment {
|
||||
starship_config: String,
|
||||
}
|
||||
|
||||
fn make_github_issue_link(starship_version: &str, environment: Environment) -> String {
|
||||
fn get_pkg_branch_tag() -> &'static str {
|
||||
if !shadow::TAG.is_empty() {
|
||||
return shadow::TAG;
|
||||
}
|
||||
shadow::BRANCH
|
||||
}
|
||||
|
||||
fn make_github_issue_link(environment: Environment) -> String {
|
||||
let body = urlencoding::encode(&format!("#### Current Behavior
|
||||
<!-- A clear and concise description of the behavior. -->
|
||||
|
||||
@@ -81,7 +89,11 @@ fn make_github_issue_link(starship_version: &str, environment: Environment) -> S
|
||||
- {shell_name} version: {shell_version}
|
||||
- Operating system: {os_name} {os_version}
|
||||
- Terminal emulator: {terminal_name} {terminal_version}
|
||||
|
||||
- Git Commit Hash: {git_commit_hash}
|
||||
- Branch/Tag: {pkg_branch_tag}
|
||||
- Rust Version: {rust_version}
|
||||
- Rust channel: {rust_channel} {build_rust_channel}
|
||||
- Build Time: {build_time}
|
||||
#### Relevant Shell Configuration
|
||||
|
||||
```bash
|
||||
@@ -93,7 +105,7 @@ fn make_github_issue_link(starship_version: &str, environment: Environment) -> S
|
||||
```toml
|
||||
{starship_config}
|
||||
```",
|
||||
starship_version = starship_version,
|
||||
starship_version = shadow::PKG_VERSION,
|
||||
shell_name = environment.shell_info.name,
|
||||
shell_version = environment.shell_info.version,
|
||||
terminal_name = environment.terminal_info.name,
|
||||
@@ -102,6 +114,12 @@ fn make_github_issue_link(starship_version: &str, environment: Environment) -> S
|
||||
os_version = environment.os_version,
|
||||
shell_config = environment.shell_info.config,
|
||||
starship_config = environment.starship_config,
|
||||
git_commit_hash = shadow::SHORT_COMMIT,
|
||||
pkg_branch_tag = get_pkg_branch_tag(),
|
||||
rust_version = shadow::RUST_VERSION,
|
||||
rust_channel = shadow::RUST_CHANNEL,
|
||||
build_rust_channel = shadow::BUILD_RUST_CHANNEL,
|
||||
build_time = shadow::BUILD_TIME,
|
||||
))
|
||||
.replace("%20", "+");
|
||||
|
||||
@@ -212,7 +230,6 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_make_github_link() {
|
||||
let starship_version = "0.1.2";
|
||||
let environment = Environment {
|
||||
os_type: os_info::Type::Linux,
|
||||
os_version: os_info::Version::Semantic(1, 2, 3),
|
||||
@@ -228,9 +245,9 @@ mod tests {
|
||||
starship_config: "No Starship config".to_string(),
|
||||
};
|
||||
|
||||
let link = make_github_issue_link(starship_version, environment);
|
||||
let link = make_github_issue_link(environment);
|
||||
|
||||
assert!(link.contains(starship_version));
|
||||
assert!(link.contains(clap::crate_version!()));
|
||||
assert!(link.contains("Linux"));
|
||||
assert!(link.contains("1.2.3"));
|
||||
assert!(link.contains("test_shell"));
|
||||
|
||||
Reference in New Issue
Block a user