mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-28 09:31:16 -03:00
tarball: remove redundant "version" file
Use the version in Cargo.toml instead.
Print a warning if the Cargo.toml version is not a prefix of the Git
version. This can happen legit scenarios, see 0dfc490721 (build.rs:
Use Cargo_PKG_VERSION if no version could be found, 2024-06-10)
but the next commit will fix that.
Also remove stale comments in git_version_gen.sh.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -152,7 +152,7 @@ checksum = "645cbb3a84e60b7531617d5ae4e57f7e27308f6445f5abf653209ea76dec8dff"
|
||||
|
||||
[[package]]
|
||||
name = "fish"
|
||||
version = "4.3.3-snapshot"
|
||||
version = "4.3.3"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
|
||||
@@ -79,7 +79,7 @@ debug = true
|
||||
|
||||
[package]
|
||||
name = "fish"
|
||||
version = "4.3.3-snapshot"
|
||||
version = "4.3.3"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
default-run = "fish"
|
||||
|
||||
9
build.rs
9
build.rs
@@ -35,7 +35,7 @@ fn main() {
|
||||
rsconf::set_env_value("BUILD_HOST_TRIPLE", &env_var("HOST").unwrap());
|
||||
rsconf::set_env_value("BUILD_PROFILE", &env_var("PROFILE").unwrap());
|
||||
|
||||
let version = &get_version(&env::current_dir().unwrap());
|
||||
let version = &get_version();
|
||||
// Per https://doc.rust-lang.org/cargo/reference/build-scripts.html#inputs-to-the-build-script,
|
||||
// the source directory is the current working directory of the build script
|
||||
rsconf::set_env_value("FISH_BUILD_VERSION", version);
|
||||
@@ -195,7 +195,7 @@ fn join_if_relative(parent_if_relative: &Path, path: String) -> PathBuf {
|
||||
});
|
||||
}
|
||||
|
||||
fn get_version(src_dir: &Path) -> String {
|
||||
fn get_version() -> String {
|
||||
use std::fs::read_to_string;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -203,11 +203,6 @@ fn get_version(src_dir: &Path) -> String {
|
||||
return var;
|
||||
}
|
||||
|
||||
let path = src_dir.join("version");
|
||||
if let Ok(strver) = read_to_string(path) {
|
||||
return strver;
|
||||
}
|
||||
|
||||
let args = &["describe", "--always", "--dirty=-dirty"];
|
||||
if let Ok(output) = Command::new("git").args(args).output() {
|
||||
let rev = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
|
||||
@@ -1,24 +1,21 @@
|
||||
#!/bin/sh
|
||||
# Originally from the git sources (GIT-VERSION-GEN)
|
||||
# Presumably (C) Junio C Hamano <junkio@cox.net>
|
||||
# Reused under GPL v2.0
|
||||
# Modified for fish by David Adam <zanchey@ucc.gu.uwa.edu.au>
|
||||
|
||||
set -e
|
||||
|
||||
# Find the fish directory as two levels up from script directory.
|
||||
FISH_BASE_DIR="$( cd "$( dirname "$( dirname "$0" )" )" && pwd )"
|
||||
DEF_VER=unknown
|
||||
|
||||
# First see if there is a version file (included in release tarballs),
|
||||
# then try git-describe, then default.
|
||||
if test -f "$FISH_BASE_DIR"/version
|
||||
then
|
||||
VN=$(cat "$FISH_BASE_DIR"/version) || VN="$DEF_VER"
|
||||
elif VN=$(git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
|
||||
:
|
||||
else
|
||||
VN="$DEF_VER"
|
||||
version=$(
|
||||
awk <"$FISH_BASE_DIR/Cargo.toml" -F'"' '$1 == "version = " { print $2 }'
|
||||
)
|
||||
if git_version=$(
|
||||
GIT_CEILING_DIRECTORIES=$FISH_BASE_DIR/.. \
|
||||
git -C "$FISH_BASE_DIR" describe --always --dirty 2>/dev/null); then
|
||||
if [ "$git_version" = "${git_version#"$version"}" ]; then
|
||||
echo >&2 "$0: warning: Cargo.toml version '$version' is not a prefix of Git version '$git_version'"
|
||||
fi
|
||||
version=$git_version
|
||||
fi
|
||||
|
||||
echo "$VN"
|
||||
echo "$version"
|
||||
|
||||
@@ -14,7 +14,6 @@ path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix.tar.xz
|
||||
|
||||
git archive \
|
||||
--prefix="$prefix/" \
|
||||
--add-virtual-file="$prefix/version:$VERSION" \
|
||||
HEAD |
|
||||
xz >"$path"
|
||||
|
||||
|
||||
@@ -83,13 +83,18 @@ sed -i \
|
||||
-e "2c$(printf %s "$changelog_title" | sed s/./=/g)" \
|
||||
CHANGELOG.rst
|
||||
|
||||
CommitVersion() {
|
||||
sed -i "s/^version = \".*\"/version = \"$1\"/g" Cargo.toml
|
||||
cargo fetch --offline
|
||||
if [ "$1" = "$version" ]; then
|
||||
# debchange is a Debian script to manage the Debian changelog, but
|
||||
# it's too annoying to install everywhere. Just do it by hand.
|
||||
cat - contrib/debian/changelog > contrib/debian/changelog.new <<EOF
|
||||
CreateCommit() {
|
||||
git commit -m "$2
|
||||
|
||||
Created by ./build_tools/release.sh $version"
|
||||
}
|
||||
|
||||
sed -i "s/^version = \".*\"/version = \"$1\"/g" Cargo.toml
|
||||
cargo fetch --offline
|
||||
if [ "$1" = "$version" ]; then
|
||||
# debchange is a Debian script to manage the Debian changelog, but
|
||||
# it's too annoying to install everywhere. Just do it by hand.
|
||||
cat - contrib/debian/changelog > contrib/debian/changelog.new <<EOF
|
||||
fish (${version}-1) stable; urgency=medium
|
||||
|
||||
* Release of new version $version.
|
||||
@@ -99,16 +104,11 @@ fish (${version}-1) stable; urgency=medium
|
||||
-- $committer $(date -R)
|
||||
|
||||
EOF
|
||||
mv contrib/debian/changelog.new contrib/debian/changelog
|
||||
git add contrib/debian/changelog
|
||||
fi
|
||||
git add CHANGELOG.rst Cargo.toml Cargo.lock
|
||||
git commit -m "$2
|
||||
|
||||
Created by ./build_tools/release.sh $version"
|
||||
}
|
||||
|
||||
CommitVersion "$version" "Release $version"
|
||||
mv contrib/debian/changelog.new contrib/debian/changelog
|
||||
git add contrib/debian/changelog
|
||||
fi
|
||||
git add CHANGELOG.rst Cargo.toml Cargo.lock
|
||||
CreateCommit "Release $version"
|
||||
|
||||
git -c "user.signingKey=$committer" \
|
||||
tag --sign --message="Release $version" $version
|
||||
@@ -279,7 +279,8 @@ fish ?.?.? (released ???)
|
||||
EOF
|
||||
)
|
||||
printf %s\\n "$changelog" >CHANGELOG.rst
|
||||
CommitVersion ${version}-snapshot "start new cycle"
|
||||
git add CHANGELOG.rst
|
||||
CreateCommit "start new cycle"
|
||||
git push $remote HEAD:master
|
||||
} fi
|
||||
|
||||
|
||||
@@ -1,2 +1,16 @@
|
||||
#RUN: %fish -v
|
||||
# CHECK: fish, version {{[0-9].*}}
|
||||
#RUN: fish=%fish %fish %s
|
||||
|
||||
# Exact tag:
|
||||
# 1.2.3
|
||||
# Git version:
|
||||
# 1.2.3-42-gdeadbeef
|
||||
# Git version when no tags are present. Distros should probably not package it like this,
|
||||
# that's why this test currently fails for such versions.
|
||||
# 1.2.3-gdeadbeef
|
||||
|
||||
$fish -v
|
||||
# CHECK: fish, version {{\d+\.\d+\.\d+(-\d+-g[0-9a-f]{7,}(-dirty)?)?$}}
|
||||
|
||||
set -l workspace_root (status dirname)/../..
|
||||
$workspace_root/build_tools/git_version_gen.sh
|
||||
# CHECK: {{\d+\.\d+\.\d+(-\d+-g[0-9a-f]{7,}(-dirty)?)?$}}
|
||||
|
||||
Reference in New Issue
Block a user