moss

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 0e3711b2217d3815f341caa2619361214d8e6ba8
parent 8f2b9182e9d2e371b716eabef58d831ede7c9072
Author: Daniel Barlow <dan@telent.net>
Date:   Tue, 10 Aug 2021 18:03:16 +0100

move find_in_subtree to Moss

Diffstat:
Mmoss.rb | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/moss.rb b/moss.rb @@ -46,6 +46,18 @@ class Moss store.join(".git").exist? end + private def find_in_subtree(subtree, filename) + pathname = subtree.join(filename) + case + when pathname.readable? + pathname + when subtree.to_s > STORE.to_s + find_in_subtree(subtree.parent, filename) + else + nil + end + end + private def recipients_for_secret(name) pathname = store.join("#{name}.age") find_in_subtree(pathname.parent, ".recipients") or @@ -98,18 +110,6 @@ def random_alnum(length) end -def find_in_subtree(subtree, filename) - pathname = subtree.join(filename) - case - when pathname.readable? - pathname - when subtree.to_s > STORE.to_s - find_in_subtree(subtree.parent, filename) - else - nil - end -end - action, *parameters = ARGV case action when 'generate'