Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions .git-hooks/pre_commit/metadata.rb
Original file line number Diff line number Diff line change
@@ -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[ ](?<short>[^\n]+\n)
(?:\n(?<full>.+))?\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
10 changes: 10 additions & 0 deletions .overcommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ PreCommit:

TrailingWhitespace:
enabled: true
exclude:
- metadata/en-US/full_description.txt

FileEncoding:
description: Check text files are valid UTF-8
Expand All @@ -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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
40 changes: 40 additions & 0 deletions metadata/en-US/full_description.txt
Original file line number Diff line number Diff line change
@@ -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/
File renamed without changes
File renamed without changes
1 change: 1 addition & 0 deletions metadata/en-US/short_description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Tasker plugin actions to allow running rsync over SSH