mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Pamhyr: Update licence.
This commit is contained in:
1 parent
0071ef22d7
commit
deaf114fa3
202 files changed
+554
-186
No files matched your search
+66
-2
@@ -1,5 +1,5 @@
|
||||
;; license.el -- Pamhyr
|
||||
;; Copyright (C) 2023 INRAE
|
||||
;; Copyright (C) 2023-2024 INRAE
|
||||
;;
|
||||
;; This program is free software: you can redistribute it and/or modify
|
||||
;; it under the terms of the GNU General Public License as published by
|
||||
@@ -24,7 +24,7 @@
|
||||
(let ((filename (pamhyr-current-filename)))
|
||||
(insert (format
|
||||
"# %s -- Pamhyr
|
||||
# Copyright (C) 2023 INRAE
|
||||
# Copyright (C) 2024 INRAE
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -41,3 +41,67 @@
|
||||
|
||||
# -*- coding: utf-8 -*-
|
||||
" filename))))
|
||||
|
||||
(defun pamhyr-update-license ()
|
||||
(interactive)
|
||||
(let ((pos (point)))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "Copyright (C) 2023 INRAE" nil t)
|
||||
(replace-match "Copyright (C) 2023-2024 INRAE"))
|
||||
(goto-char pos)))
|
||||
|
||||
(defun pamhyr-root-dir-rec-aux (dir)
|
||||
(if (or (equal dir "")
|
||||
(equal dir "/")
|
||||
(equal dir nil))
|
||||
nil
|
||||
(let ((ndir (directory-file-name (file-name-directory dir))))
|
||||
(if (file-directory-p (concat ndir "/.git"))
|
||||
ndir
|
||||
(pamhyr-root-dir-rec-aux ndir)))))
|
||||
|
||||
(defun pamhyr-root-dir ()
|
||||
(pamhyr-root-dir-rec-aux (buffer-file-name)))
|
||||
|
||||
(defun pamhyr--update-license (file)
|
||||
(message (format "Update: %s" file))
|
||||
(let ((buffer (find-file file)))
|
||||
(with-current-buffer buffer
|
||||
(pamhyr-update-license)
|
||||
(save-buffer))
|
||||
;(kill-buffer buffer)
|
||||
))
|
||||
|
||||
(defun pamhyr--insert-license (file)
|
||||
(message (format "License: %s" file))
|
||||
(let ((buffer (find-file file)))
|
||||
(with-current-buffer buffer
|
||||
(goto-char (point-min))
|
||||
(pamhyr-insert-license)
|
||||
(save-buffer))
|
||||
;(kill-buffer buffer)
|
||||
))
|
||||
|
||||
(defun pamhyr-update-all-license ()
|
||||
(interactive)
|
||||
(let* ((root (pamhyr-root-dir))
|
||||
(files-with-copyright (split-string
|
||||
(shell-command-to-string
|
||||
(format "git -C '%s' grep -e 'Copyright (C)'|cut -d ':' -f 1|uniq|grep [.]py"
|
||||
root))
|
||||
"\n"))
|
||||
(files (split-string
|
||||
(shell-command-to-string
|
||||
(format "git -C '%s' ls-files | grep [.]py"
|
||||
root))))
|
||||
(files-without-copyright (seq-filter (lambda (file)
|
||||
(not (member file files-with-copyright)))
|
||||
files)))
|
||||
(message (format "%s" files-with-copyright))
|
||||
(mapcar 'pamhyr--update-license (mapcar (lambda (file) (concat root "/" file))
|
||||
files-with-copyright))
|
||||
|
||||
(message (format "%s" files-without-copyright))
|
||||
(mapcar 'pamhyr--insert-license
|
||||
(mapcar (lambda (file) (concat root "/" file))
|
||||
files-without-copyright))))
|
||||
Reference in new issue
Block a user