From: "Vladimir D. Seleznev" <vseleznv@altlinux.org>
To: devel@lists.altlinux.org
Cc: legion@altlinux.org, "Vladimir D. Seleznev" <vseleznv@altlinux.org>
Subject: [devel] [PATCH] Introduce nodiff directive for gear-rules
Date: Tue, 10 Nov 2020 06:16:09 +0300
Message-ID: <20201110031608.2185196-2-vseleznv@altlinux.org> (raw)
In-Reply-To: <20201110031608.2185196-1-vseleznv@altlinux.org>
The directive specifies whitespace-separated list of glob patterns that
define files that should be excluded from diff generation.
Signed-off-by: Vladimir D. Seleznev <vseleznv@altlinux.org>
---
gear | 24 ++++++++++++++++++------
gear-rules.5.in | 18 ++++++++++++++++++
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/gear b/gear
index 6282c92..0589b06 100755
--- a/gear
+++ b/gear
@@ -402,13 +402,14 @@ write_git_diff()
{
local optional="$1" && shift
local cmd="$1" && shift
+ local nodiff_patterns="$1" && shift
local old_tree="$1" && shift
local old_dir="$1" && shift
local new_tree="$1" && shift
local new_dir="$1" && shift
local name="${1##*/}" && shift
- local old_id new_id
+ local old_id new_id nodiff=
old_id="$(traverse_tree "$old_tree" "$old_dir" "$optional")" ||
{
@@ -422,8 +423,13 @@ write_git_diff()
exit 1
}
+ for pattern in $nodiff_patterns; do
+ [ -n "$pattern" ] ||continue
+ nodiff="$nodiff $(printf ":^%s" "$pattern")"
+ done
+
git diff-tree --patch-with-stat --text --no-renames --no-ext-diff \
- "$old_id" "$new_id" >"$outdir/$name"
+ "$old_id" "$new_id" $nodiff >"$outdir/$name"
verbose "Extracted diff: $name"
compress_file "$cmd" "$name" ''
@@ -436,6 +442,7 @@ make_difference()
rules_error 'No old_dir or new_dir specified'
local optional="$1" && shift
local cmd="$1" && shift
+ local nodiff_patterns="$1" && shift
local old_dir="$1" && shift
local new_dir="$1" && shift
@@ -456,7 +463,7 @@ make_difference()
diff_new_tree="$(resolve_tree_base_name "$diff_new_tree")" ||
rules_error "Invalid new tree: $diff_new_tree"
- write_git_diff "$optional" "$cmd" "$diff_old_tree" "$old_dir" "$diff_new_tree" "$new_dir" "$diff_name"
+ write_git_diff "$optional" "$cmd" "$nodiff_patterns" "$diff_old_tree" "$old_dir" "$diff_new_tree" "$new_dir" "$diff_name"
}
extract_pattern()
@@ -564,7 +571,7 @@ parse_rules()
exclude_pattern_list=
lineno=0
- local cmd options
+ local cmd options nodiff_patterns=
while read -r cmd options; do
lineno="$((lineno+1))"
if [ "$cmd" = 'exclude:' ]; then
@@ -572,6 +579,11 @@ parse_rules()
rules_error "Invalid exclude pattern specified: $options"
exclude_pattern_list="$exclude_pattern_list $options"
fi
+ if [ "$cmd" = 'nodiff:' ]; then
+ [ -z "$(printf %s "$options" |tr -d '[:alnum:]_.?*-/ ')" ] ||
+ rules_error "Invalid nodiff pattern specified: $options"
+ nodiff_patterns="$nodiff_patterns $options"
+ fi
done <"$workdir/rules"
lineno=0
@@ -601,7 +613,7 @@ parse_rules()
eval "set -- $opts"
case "$cmd" in
- spec|specsubst|exclude|tags)
+ spec|specsubst|exclude|tags|nodiff)
continue
;;
tar|tar.gz|tar.bz2|tar.lzma|tar.xz|tar.zst)
@@ -613,7 +625,7 @@ parse_rules()
rules_error 'Failed to make archive'
;;
diff|diff.gz|diff.bz2|diff.lzma|diff.xz|diff.zst)
- make_difference "$optional" "$cmd" "$@" ||
+ make_difference "$optional" "$cmd" "$nodiff_patterns" "$@" ||
rules_error 'Failed to make diff'
;;
copy|gzip|bzip2|lzma|xz|zstd)
diff --git a/gear-rules.5.in b/gear-rules.5.in
index 5469199..c1b6793 100644
--- a/gear-rules.5.in
+++ b/gear-rules.5.in
@@ -452,6 +452,12 @@ or
.I new_tree_path
specify non-default base trees, these trees still must be valid.
.TP
+.BI "nodiff: " glob_pattern...
+Specify whitespace-separated list of glob patterns that define files that
+should be excluded from diff generation. Affects all directives in the
+rule file irrespective of the order. Specifying a glob pattern which does not
+match any files in the tree is not an error.
+.TP
.BI "specsubst: " variables...
Specify whitespace-separated list of variables that should be substituted
in specfile. Variable names may contain letters, digits and underscore
@@ -541,6 +547,18 @@ However, if a prerelease version is packaged, parts like
\*(lqpreN\*(rq or \*(lqrcN\*(rq should not be included in the package
version, therefore the rule file will need some modifications for such
versions.
+.PP
+You can also want to exclude
+.BR .gear
+subdirectory and spec file from diff generation:
+.RS 4
+.PP
+.ft CW
+.nf
+nodiff: .gear/** *.spec
+.fi
+.RE
+.PP
.
.SS "Archive with unmodified sources and separate patch files"
If you prefer to maintain patch files for local modifications instead
--
2.25.4
next prev parent reply other threads:[~2020-11-10 3:16 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 3:16 [devel] Introduce gear-rules nodiff directive Vladimir D. Seleznev
2020-11-10 3:16 ` Vladimir D. Seleznev [this message]
2020-11-10 10:47 ` [devel] [PATCH] Introduce nodiff directive for gear-rules Alexey Gladkov
2020-11-10 4:27 ` [devel] Introduce gear-rules nodiff directive Антон Мидюков
2020-11-10 7:53 ` Sergey V Turchin
2020-11-10 8:01 ` Anton Farygin
2020-11-10 9:02 ` Andrey Savchenko
2020-11-10 10:24 ` Vitaly Lipatov
2020-11-10 13:07 ` Sergey V Turchin
2020-11-10 14:47 ` Dmitry V. Levin
2020-11-11 7:16 ` Anton V. Boyarshinov
2020-11-11 8:14 ` Anton Farygin
2020-11-10 8:03 ` Anton Farygin
2020-11-10 15:20 ` Vladimir D. Seleznev
2020-11-11 6:25 ` Anton Farygin
2020-11-10 12:46 ` Arseny Maslennikov
2020-11-10 15:51 ` Vladimir D. Seleznev
2020-11-10 16:15 ` Andrey Savchenko
2020-11-10 16:22 ` Vladimir D. Seleznev
2020-11-10 17:00 ` Andrey Savchenko
2020-11-10 18:26 ` [devel] gear-rules: new directive name Arseny Maslennikov
2020-11-10 18:47 ` [devel] Introduce gear-rules nodiff directive Michael Shigorin
2020-11-11 8:07 ` Sergey V Turchin
2020-11-10 17:30 ` Alexey V. Vissarionov
2020-11-10 14:48 ` Dmitry V. Levin
2020-11-10 14:54 ` Sergey V Turchin
2020-11-10 15:29 ` Vladimir D. Seleznev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201110031608.2185196-2-vseleznv@altlinux.org \
--to=vseleznv@altlinux.org \
--cc=devel@lists.altlinux.org \
--cc=legion@altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git