Add a mix alias to bump copyright
authorMark Felder <feld@feld.me>
Fri, 15 Jan 2021 23:26:02 +0000 (17:26 -0600)
committerMark Felder <feld@feld.me>
Fri, 15 Jan 2021 23:26:02 +0000 (17:26 -0600)
mix.exs

diff --git a/mix.exs b/mix.exs
index 1bfca0b474135212b016df806853b0c60fec2db0..281cca6433fbd3deaec616c7b2fe4c26ab3752d3 100644 (file)
--- a/mix.exs
+++ b/mix.exs
@@ -230,7 +230,8 @@ defmodule Pleroma.Mixfile do
       test: ["ecto.create --quiet", "ecto.migrate", "test"],
       docs: ["pleroma.docs", "docs"],
       analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
-      copyright: &add_copyright/1
+      copyright: &add_copyright/1,
+      "copyright.bump": &bump_copyright/1
     ]
   end
 
@@ -349,4 +350,13 @@ defmodule Pleroma.Mixfile do
 
     :os.cmd(String.to_charlist("#{find}#{grep}#{xargs}"))
   end
+
+  defp bump_copyright(_) do
+    year = NaiveDateTime.utc_now().year
+    find = "find lib test priv -type f \\( -name '*.ex' -or -name '*.exs' \\) |"
+
+    xargs = "xargs sed -i '' 's/# Copyright © 2017-20[0-9][0-9]/# Copyright © 2017-#{year}/'"
+
+    :os.cmd(String.to_charlist("#{find}#{xargs}"))
+  end
 end