Skip to content

Commit 12e4180

Browse files
committed
doc: remove CPU features from man pages
It doesn't really belong in the man page since it's an artifact of a build/runtime configuration. Moreover, it inhibits reproducible builds. Fixes #1441
1 parent daa8319 commit 12e4180

File tree

3 files changed

+27
-19
lines changed

3 files changed

+27
-19
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ Bug fixes:
5757
Fixes a bug where ripgrep would panic when searching a symlinked directory.
5858
* [BUG #1439](https://github.com/BurntSushi/ripgrep/issues/1439):
5959
Improve documentation for ripgrep's automatic stdin detection.
60+
* [BUG #1441](https://github.com/BurntSushi/ripgrep/issues/1441):
61+
Remove CPU features from man page.
6062
* [BUG #1445](https://github.com/BurntSushi/ripgrep/issues/1445):
6163
ripgrep now respects ignore rules from .git/info/exclude in worktrees.
6264
* [BUG #1485](https://github.com/BurntSushi/ripgrep/issues/1485):

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn generate_man_page<P: AsRef<Path>>(outdir: P) -> io::Result<()> {
8686

8787
let githash = git_revision_hash();
8888
let githash = githash.as_ref().map(|x| &**x);
89-
tpl = tpl.replace("{VERSION}", &app::long_version(githash));
89+
tpl = tpl.replace("{VERSION}", &app::long_version(githash, false));
9090

9191
File::create(&txt_path)?.write_all(tpl.as_bytes())?;
9292
let result = process::Command::new("a2x")

crates/core/app.rs

+24-18
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pub fn app() -> App<'static, 'static> {
6666
// 'static, but we need to build the version string dynamically. We can
6767
// fake the 'static lifetime with lazy_static.
6868
lazy_static! {
69-
static ref LONG_VERSION: String = long_version(None);
69+
static ref LONG_VERSION: String = long_version(None, true);
7070
}
7171

7272
let mut app = App::new("ripgrep")
@@ -91,30 +91,36 @@ pub fn app() -> App<'static, 'static> {
9191
/// If a revision hash is given, then it is used. If one isn't given, then
9292
/// the RIPGREP_BUILD_GIT_HASH env var is inspected for it. If that isn't set,
9393
/// then a revision hash is not included in the version string returned.
94-
pub fn long_version(revision_hash: Option<&str>) -> String {
94+
///
95+
/// If `cpu` is true, then the version string will include the compiled and
96+
/// runtime CPU features.
97+
pub fn long_version(revision_hash: Option<&str>, cpu: bool) -> String {
9598
// Do we have a git hash?
9699
// (Yes, if ripgrep was built on a machine with `git` installed.)
97100
let hash = match revision_hash.or(option_env!("RIPGREP_BUILD_GIT_HASH")) {
98101
None => String::new(),
99102
Some(githash) => format!(" (rev {})", githash),
100103
};
101-
// Put everything together.
102-
let runtime = runtime_cpu_features();
103-
if runtime.is_empty() {
104-
format!(
105-
"{}{}\n{} (compiled)",
106-
crate_version!(),
107-
hash,
108-
compile_cpu_features().join(" ")
109-
)
104+
if !cpu {
105+
format!("{}{}", crate_version!(), hash,)
110106
} else {
111-
format!(
112-
"{}{}\n{} (compiled)\n{} (runtime)",
113-
crate_version!(),
114-
hash,
115-
compile_cpu_features().join(" "),
116-
runtime.join(" ")
117-
)
107+
let runtime = runtime_cpu_features();
108+
if runtime.is_empty() {
109+
format!(
110+
"{}{}\n{} (compiled)",
111+
crate_version!(),
112+
hash,
113+
compile_cpu_features().join(" ")
114+
)
115+
} else {
116+
format!(
117+
"{}{}\n{} (compiled)\n{} (runtime)",
118+
crate_version!(),
119+
hash,
120+
compile_cpu_features().join(" "),
121+
runtime.join(" ")
122+
)
123+
}
118124
}
119125
}
120126

0 commit comments

Comments
 (0)