Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 83 lines (69 sloc) 2.52 KB
#!/bin/sh
# Copyright: SZABO Gergely <szg@subogero.com>
# License : WTFPL v2 <http://www.wtfpl.net/txt/copying/>
usage ()
{
cat <<EOF
Usage:
redupdate -p <project> -s <subject> [-u <url>] | -e <email> [FILE]
redupdate -i <issue> -u <url> | -e <email> [FILE]
Creates or updates a Redmine issue, reading the text of the issue description
or issue-update from FILE or stadard input if FILE is not specified.
-i <issue> Issue number (without #) if you're updating an issue
-p <project> Project id if you're creating an issue
-s <subject> Issue title, use only together with -p
-u <url> URL to access the Redmine server via SSH in format user@server
taken from ~/.redgit if omitted
-e <email> Email address of Author or Updater, when on the Redmine server
When working directly on the Redmine server, specify your email with -e.
When accessing a remote Redmine server, specify its URL with -u.
In the latter case, redupdate tries to extract your email address from
git config if you don't specify it.
When creating or updating an issue, you can use keywords for issue fields:
Tracker: <name>
Category: <name>
Priority: <name>
Status: <name>
Assigned to: <name> | <login>
<Custom Field>: <name>
In Redmine Administration / Settings / Incoming Emails you need to
Enable WS for incoming emails and save the API key into the /etc/redmine-key.
EOF
exit $1
}
# Input handling
[ "$1" = '-h' ] && usage 0
while [ "$1" ]; do
if [ "$1" = '-i' ]; then shift; subject="Subject: Re: [#$1]"; shift
elif [ "$1" = '-p' ]; then shift; project="-p $1"; shift
elif [ "$1" = '-s' ]; then shift; subject="Subject: $1"; shift
elif [ "$1" = '-e' ]; then shift; from="From: $1"; shift
elif [ "$1" = '-u' ]; then shift; url=$1; shift
else file=$1; shift
fi
done
# SSH URL from config file if omitted
if [ -z "$url" -a -f ~/.redgit ]; then
url=`sed -rn '/^\[redgit\]/,/^\[/p' ~/.redgit | sed -rn 's/ssh=(.+)/\1/p'`
fi
# Email address from git config if necessary
[ "$url" -a -z "$from" ] && from="From: `git config --get user.email`"
# Error checking
[ -z "$subject" -o -z "$from" ] && usage 1
# The issue update/description message
message="$from
To: redmine@localhost
$subject
`cat $file`"
# The command to execute
command="/usr/share/redmine/extra/mail_handler/rdm-mailhandler.rb \
--url=http://localhost/redmine \
"'--key=`cat /etc/redmine-key`'" \
-o project,tracker,category,priority,status,assigned_to,fixed_version \
$project"
# The real thing
if [ "$url" ]; then
echo "$message" | ssh $url "$command"
else
echo "$message" | $command
fi