Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] repoman.modules.vcs.git.changes: reindex (bug 712106)
Date: Wed, 11 Mar 2020 16:37:36
Message-Id: CAAr7Pr8urgvoOkomcua9cSQXZCtFG=chMMm9kW6Yep8DEZSMGQ@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH] repoman.modules.vcs.git.changes: reindex (bug 712106) by Zac Medico
1 On Wed, Mar 11, 2020 at 12:16 AM Zac Medico <zmedico@g.o> wrote:
2
3 > For files returned by git diff-index, call git update-index in order
4 > to ensure that the index reflects the state on disk. This will prevent
5 > incorrect assumptions in cases where the index is missing or stale for
6 > some reason. Since repoman uses this information to decide when to
7 > update copyright header dates, this can prevent spurious copyright
8 > header updates.
9 >
10 > Signed-off-by: Zac Medico <zmedico@g.o>
11 > Bug: https://bugs.gentoo.org/712106
12 > ---
13 > repoman/lib/repoman/modules/vcs/git/changes.py | 15 ++++++++++++---
14 > 1 file changed, 12 insertions(+), 3 deletions(-)
15 >
16 > diff --git a/repoman/lib/repoman/modules/vcs/git/changes.py
17 > b/repoman/lib/repoman/modules/vcs/git/changes.py
18 > index 7e9ac1eb5..ebf770d53 100644
19 > --- a/repoman/lib/repoman/modules/vcs/git/changes.py
20 > +++ b/repoman/lib/repoman/modules/vcs/git/changes.py
21 > @@ -29,8 +29,14 @@ class Changes(ChangesBase):
22 > '''
23 > super(Changes, self).__init__(options, repo_settings)
24 >
25 > - def _scan(self):
26 > - '''VCS type scan function, looks for all detectable
27 > changes'''
28 > + def _scan(self, _reindex=True):
29 >
30
31 Why the underscore prefix?
32
33 -A
34
35
36 > + '''
37 > + VCS type scan function, looks for all detectable changes
38 > +
39 > + @param _reindex: ensure that the git index reflects the
40 > state on
41 > + disk for files returned by git diff-index
42 > + @type _reindex: bool
43 > + '''
44 > with repoman_popen(
45 > "git diff-index --name-only "
46 > "--relative --diff-filter=M HEAD") as f:
47 > @@ -51,6 +57,9 @@ class Changes(ChangesBase):
48 > removed = f.readlines()
49 > self.removed = ["./" + elem[:-1] for elem in removed]
50 > del removed
51 > + if _reindex and (self.changed or self.new or self.removed):
52 > + self.update_index([], self.changed + self.new +
53 > self.removed)
54 > + self._scan(_reindex=False)
55 >
56 > @property
57 > def unadded(self):
58 > @@ -91,7 +100,7 @@ class Changes(ChangesBase):
59 > # of the working tree.
60 > myfiles = mymanifests + myupdates
61 > myfiles.sort()
62 > - update_index_cmd = ["git", "update-index"]
63 > + update_index_cmd = ["git", "update-index", "--add",
64 > "--remove"]
65 > update_index_cmd.extend(f.lstrip("./") for f in myfiles)
66 > if self.options.pretend:
67 > print("(%s)" % (" ".join(update_index_cmd),))
68 > --
69 > 2.24.1
70 >
71 >
72 >

Replies