-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid varying git archive content for ref; rework versioning
Don't include the log --decorate names in the archive via export-subst because they can change after the fact when new tags or branches are added for a given hash -- for example, when we created the 0.30.x branch after tagging 0.30.1. Archives retrieved before the branch was created would have a different set of NAMES in _release.py. Move _release to source_info and add an optional checkout_info module. source_info contains the (no longer variable) export-subst commit hash and date values, and checkout_info contains the same data for a git checkout. Automatically update checkout_info whenever we're at the top level of a git source tree, but don't include it in the archives. Record the base version in version.py explicitly as either a release version like 0.31, for an actual release (which must be committted before tagging the release), or a development version like 0.31~ (indicating a version that's always less than 0.31). Rework bup version to report the lib/version for an actual release, or that version suffixed with the commit hash when running a non-release, and add a "+" when uncommitted modifications are detected. For example: release: 0.31 non-release: 0.31~4e4b9ba8689c93702743c8ecd49c5a7808a4d717 modified: 0.31~4e4b9ba8689c93702743c8ecd49c5a7808a4d717+ Drop the --tag argument from bup version since the tags are variable, and you can always ask git to describe the hash via git describe --always HASH Add dev/refresh, similar to moreutils sponge, to handle file creation safely, something we may want to deploy more widely (e.g. instead of the $$/PID based tempfiles in the Makefile). Thanks to Greg Troxel for reporting the problem. Signed-off-by: Rob Browning <[email protected]> Tested-by: Rob Browning <[email protected]>
- Loading branch information
Showing
12 changed files
with
194 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ueo pipefail | ||
|
||
# Related: https://joeyh.name/code/moreutils/ sponge | ||
|
||
usage() | ||
{ | ||
echo 'Usage: refresh [-a] [-v] DEST' | ||
echo ' refresh [-a] [-v] -- DEST' | ||
} | ||
|
||
append='' | ||
verbose='' | ||
|
||
while test $# -gt 0; do | ||
case $1 in | ||
-a) append=true; shift;; | ||
-v) verbose=true; shift;; | ||
--) | ||
if test "$#" -ne 2; then | ||
usage 1>&2 | ||
exit 2 | ||
fi | ||
dest="$2" | ||
shift 2 | ||
;; | ||
-*) | ||
usage 1>&2 | ||
exit 2 | ||
;; | ||
*) | ||
if test "$#" -ne 1; then | ||
usage 1>&2 | ||
exit 2 | ||
fi | ||
dest="$1" | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
tmpfile="$(mktemp "$dest.sponge-XXXXXXX")" | ||
|
||
clean-up() | ||
{ | ||
rm -f "$tmpfile" | ||
} | ||
|
||
trap clean-up EXIT | ||
|
||
# Inefficient, but should clone the permissions | ||
if test -e "$dest"; then | ||
cp -Lp "$dest" "$tmpfile" | ||
fi | ||
|
||
if test "$append"; then | ||
cat >> "$tmpfile" | ||
else | ||
cat > "$tmpfile" | ||
fi | ||
|
||
if ! cmp -s "$tmpfile" "$dest"; then | ||
if test "$verbose"; then | ||
echo "Refreshed $dest" 1>&2 | ||
fi | ||
mv "$tmpfile" "$dest" | ||
fi |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
top="$(pwd)" | ||
|
||
usage() { echo 'Usage: update-checkout-info DEST'; } | ||
|
||
if test "$#" -ne 1; then | ||
usage 1>&2; exit 1 | ||
fi | ||
|
||
dest="$1" | ||
|
||
if ! test -f lib/bup/bupsplit.c; then | ||
echo 'error: cannot find bup source tree' 1>&2 | ||
exit 1 | ||
fi | ||
|
||
git_top=$(git rev-parse --show-toplevel) || true | ||
if test "$git_top" != "$top"; then | ||
# Not a checkout, or perhaps we're building from an archive dir | ||
# unpacked somewhere in the source tree. | ||
rm -f "$dest" | ||
exit 0 | ||
fi | ||
|
||
local_changes=$(git status --porcelain -uno) | ||
|
||
(git log -1 --pretty="commit='%H'%ndate='%ci'" | ||
echo -n 'modified=' | ||
if test "$local_changes"; then echo True; else echo False; fi) \ | ||
| dev/refresh -v -- "$dest" |
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 +1 @@ | ||
_release.py export-subst | ||
source_info.py export-subst |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
commit='$Format:%H$' | ||
date='$Format:%ci$' | ||
modified=False |
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,9 +1,35 @@ | ||
|
||
from __future__ import absolute_import | ||
from __future__ import absolute_import, print_function | ||
import sys | ||
|
||
from bup import _release | ||
from bup.compat import ModuleNotFoundError | ||
|
||
if _release.COMMIT != '$Format:%H$': | ||
from bup._release import COMMIT, DATE, NAMES | ||
from bup import source_info | ||
try: | ||
import bup.checkout_info as checkout_info | ||
except ModuleNotFoundError: | ||
checkout_info = None | ||
pass | ||
|
||
|
||
if checkout_info: | ||
date = checkout_info.date.encode('ascii') | ||
commit = checkout_info.commit.encode('ascii') | ||
modified = checkout_info.modified | ||
else: | ||
from bup._checkout import COMMIT, DATE, NAMES | ||
date = source_info.date.encode('ascii') | ||
commit = source_info.commit.encode('ascii') | ||
modified = source_info.modified | ||
assert not date.startswith(b'$Format') | ||
assert not commit.startswith(b'$Format') | ||
|
||
# The ~ in a version is a Debian-style "always less than" marker: | ||
# https://www.debian.org/doc/debian-policy/ch-controlfields.html#version | ||
base_version = b'0.31~' | ||
|
||
version = base_version | ||
if version.endswith(b'~'): | ||
version += commit | ||
|
||
if modified: | ||
version += b'+' |
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
Oops, something went wrong.