diff --git a/.git-hooks/pre_commit/metadata.rb b/.git-hooks/pre_commit/metadata.rb new file mode 100644 index 0000000..6fb633f --- /dev/null +++ b/.git-hooks/pre_commit/metadata.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true + +# Copyright © 2025 Matt Robinson +# +# SPDX-License-Identifier: GPL-3.0-or-later + +module Overcommit + module Hook + module PreCommit + class Metadata < Base + README = 'README.md' + SHORT_DESCRIPTION = 'metadata/en-US/short_description.txt' + FULL_DESCRIPTION = 'metadata/en-US/full_description.txt' + + def file_error_message(file, error) + Overcommit::Hook::Message.new( + :error, + file, + nil, + "#{file}: #{error}" + ) + end + + def run + messages = [] + + content = included_files.to_h do |file| + relfile = file.delete_prefix("#{Overcommit::Utils.repo_root}/") + [relfile, File.read(file)] + end + + readme = content.delete(README) + + # Remove the first sub-heading and all content after it + readme.gsub!(/\n\n[^\n]+\n---+\n\n.*\Z/m, '') + + matches = / + \A[^\n]+\n===+\n\n + An[ ]Android[ ]app[ ]providing[ ](?[^\n]+\n) + (?:\n(?.+))?\Z + /mx.match(readme) + + if matches.nil? + return [file_error_message(README, 'Unexpected format')] + end + + unless content[SHORT_DESCRIPTION] == matches[:short].sub(/.$/, '') + messages << file_error_message( + SHORT_DESCRIPTION, + 'Does not match README' + ) + end + + unless content[FULL_DESCRIPTION] == matches[:full].gsub(/ \\$/, ' ') + messages << file_error_message( + FULL_DESCRIPTION, + 'Does not match README' + ) + end + + messages + end + end + end + end +end diff --git a/.overcommit.yml b/.overcommit.yml index 40009ff..da3a4eb 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -12,6 +12,8 @@ PreCommit: TrailingWhitespace: enabled: true + exclude: + - metadata/en-US/full_description.txt FileEncoding: description: Check text files are valid UTF-8 @@ -35,3 +37,11 @@ PreCommit: description: Check CI instrumented test coverage of API levels enabled: true include: app/build.gradle.kts + + Metadata: + description: Check that metadata matches the readme + enabled: true + include: + - README.md + - metadata/en-US/short_description.txt + - metadata/en-US/full_description.txt diff --git a/README.md b/README.md index 422842c..3bf69a1 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ plugin architecture that allows other apps (such as this one) to add extra functionality. This app provides the following actions for use within Tasker: + - Generate Private Key - Generates a private key to use for SSH authentication - Get Public Key - Retrieves a public key from a previously generated private key and returns it in the variable `%pubkey` diff --git a/metadata/en-US/full_description.txt b/metadata/en-US/full_description.txt new file mode 100644 index 0000000..a290cfc --- /dev/null +++ b/metadata/en-US/full_description.txt @@ -0,0 +1,40 @@ +[Tasker][1] is a very useful and widely used automation app for Android with a +plugin architecture that allows other apps (such as this one) to add extra +functionality. + +This app provides the following actions for use within Tasker: + + - Generate Private Key - Generates a private key to use for SSH authentication + - Get Public Key - Retrieves a public key from a previously generated private + key and returns it in the variable `%pubkey` + - rsync - Run an rsync command to synchronise files to or from the device + - dbclient - Run an SSH command non-interactively (experimental) + +The packaged native binaries of [Dropbear][2] and [rsync][3] are my own builds +which I keep updated with new releases. + +Reasons for requested permissions: + + - `FOREGROUND_SERVICE` + Run actions for more than a short time when triggered from older versions of + Tasker. + - `FOREGROUND_SERVICE_SPECIAL_USE` + (Android 14+) Run actions for more than a short time when triggered from + older versions of Tasker. + - `INTERNET` + Allow connecting to SSH servers (even if the SSH server is on your local + network Android prevents connections without this permission). + - `MANAGE_EXTERNAL_STORAGE` + (Android 11+) To read or write the files on your device with rsync. + - `WRITE_EXTERNAL_STORAGE` + (Android 10 and below) To read or write the files on your device with rsync. + - `POST_NOTIFICATIONS` + Show a notification that a new version is available (if checking for updates + is enabled). + - `REQUEST_INSTALL_PACKAGES` + Prompt to install an update after you have tapped on the update notification + and chosen 'Download'. + +[1]: https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm +[2]: https://matt.ucc.asn.au/dropbear/dropbear.html +[3]: https://rsync.samba.org/ diff --git a/images/feature_graphic.png b/metadata/en-US/images/featureGraphic.png similarity index 100% rename from images/feature_graphic.png rename to metadata/en-US/images/featureGraphic.png diff --git a/images/ic_launcher-playstore.png b/metadata/en-US/images/icon.png similarity index 100% rename from images/ic_launcher-playstore.png rename to metadata/en-US/images/icon.png diff --git a/metadata/en-US/short_description.txt b/metadata/en-US/short_description.txt new file mode 100644 index 0000000..44571ad --- /dev/null +++ b/metadata/en-US/short_description.txt @@ -0,0 +1 @@ +Tasker plugin actions to allow running rsync over SSH