Discussion:
[gentoo-portage-dev] [PATCH] repoman: regen thick manifest after copyright update (bug 656698)
Zac Medico
2018-09-20 20:39:18 UTC
Permalink
Bug: https://bugs.gentoo.org/656698
---
repoman/lib/repoman/actions.py | 14 +++++++++++++-
repoman/lib/repoman/copyrights.py | 10 ++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/repoman/lib/repoman/actions.py b/repoman/lib/repoman/actions.py
index 8e23322c8..05c63b824 100644
--- a/repoman/lib/repoman/actions.py
+++ b/repoman/lib/repoman/actions.py
@@ -151,10 +151,22 @@ the whole commit message to abort.

# Update copyright for new and changed files
year = time.strftime('%Y', time.gmtime())
+ updated_copyright = []
for fn in chain(mynew, mychanged):
if fn.endswith('.diff') or fn.endswith('.patch'):
continue
- update_copyright(fn, year, pretend=self.options.pretend)
+ if update_copyright(fn, year, pretend=self.options.pretend):
+ updated_copyright.append(fn)
+
+ if updated_copyright and not self.repo_settings.repo_config.thin_manifest:
+ for x in sorted(vcs_files_to_cps(
+ iter(updated_copyright),
+ self.repo_settings.repodir,
+ self.scanner.repolevel,
+ self.scanner.reposplit,
+ self.scanner.categories)):
+ self.repoman_settings["O"] = os.path.join(self.repo_settings.repodir, x)
+ digestgen(mysettings=self.repoman_settings, myportdb=self.repo_settings.portdb)

myupdates, broken_changelog_manifests = self.changelogs(
myupdates, mymanifests, myremoved, mychanged, myautoadd,
diff --git a/repoman/lib/repoman/copyrights.py b/repoman/lib/repoman/copyrights.py
index 1eaaab660..275dcbc3f 100644
--- a/repoman/lib/repoman/copyrights.py
+++ b/repoman/lib/repoman/copyrights.py
@@ -67,6 +67,15 @@ def update_copyright(fn_path, year, pretend=False):
Files are read and written in binary mode, so that this function
will work correctly with files encoded in any character set, as
long as the copyright statements consist of plain ASCII.
+
+ @param fn_path: file path
+ @type str
+ @param year: current year
+ @type str
+ @param pretend: pretend mode
+ @type bool
+ @rtype: bool
+ @return: True if copyright update was needed, False otherwise
"""

try:
@@ -120,3 +129,4 @@ def update_copyright(fn_path, year, pretend=False):
else:
util.apply_stat_permissions(fn_path, fn_stat)
fn_hdl.close()
+ return difflines > 3
--
2.16.4
Loading...