Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
968f10ab
Commit
968f10ab
authored
Sep 04, 2013
by
Robert Ricci
Browse files
Add ability to read main options from a config file
parent
a390f07c
Changes
1
Hide whitespace changes
Inline
Side-by-side
tools/git/gitmaild
View file @
968f10ab
...
...
@@ -5,8 +5,6 @@
# Note: *must* be run on the same host, and have permission to read the
# git repos in gitlab's home
# TODO: Support ignoring commits from repo you forked from
# TODO: Accept options in URL
# TODO: Read options from a file
# TODO: Better error handling; try really hard not to die
#
...
...
@@ -36,47 +34,71 @@ use strict;
#
#
# Settable options
# Settable options - these can be set here, or by passing a config file on the
# command line. This config file is simple a perl file that will be eval'ed, so
# just set variables there as you would here, they will override the defaults
#
# The only mandatory option: Token to use when calling gitmail API - should
# belong to an administrator
my
$TOKEN
=
"";
# Unless specified, send mail to this email address on all commits
my
$DEFAULT_ARCHIVEMAIL
=
'
commits@flux.utah.edu
';
# Path to gitmail - defaults to same directory as gmaild lives in
my
$GITMAIL
=
dirname
(
abs_path
(
$
0
))
.
"
/gitmail
";
# Port to run on - made up crap
my
$PORT
=
4577
;
# Token to use when calling gitmail API - should belong to an administrator
my
$TOKEN
=
"";
# URL used to make gitlab API calls
>>>>>>>
344221
c
...
Clean
up
and
document
options
my
$BASEURL
=
"
http://git.flux.utah.edu/
";
# Path where gitlab repos live in the FS - doesn't seem available through
# the gitlab API
my
$BASEPATH
=
"
/home/git/repositories
";
# Unless specified, send mail to this email address on all commits
my
$DEFAULT_ARCHIVEMAIL
=
'
ricci@cs.utah.edu
';
#
# End settable options
#
#
# Command line options
# TODO: actually accept on command line
#
my
$verbose
=
0
;
my
$debug
=
0
;
my
$configfile
=
undef
;
my
$result
=
GetOptions
("
v
"
=>
\
$verbose
,
"
d
"
=>
\
$debug
);
my
$result
=
GetOptions
("
v
"
=>
\
$verbose
,
"
d
"
=>
\
$debug
,
"
c:s
"
=>
\
$configfile
);
sub
run_gitmail
($$);
sub
format_options
(@);
sub
call_gitlab_api
($);
sub
get_member_addresses
($);
#
# Parse config file if given
#
if
(
$configfile
)
{
open
CF
,
"
<
$configfile
"
||
die
"
Unable to open
$configfile
: $!
\n
";
my
$configdata
=
"";
while
(
my
$data
=
<
CF
>
)
{
$configdata
.=
$data
;
}
close
CF
;
if
(
!
defined
(
eval
$configdata
))
{
die
"
Error in
$configfile
: $!
\n
";
}
}
#
# Make sure they gave a key, ain't gonna work without one
#
if
(
$TOKEN
eq
"")
{
die
"
Must set a
\$
TOKEN!
\n
";
}
#
# Open up a new socket - runs only on localhost, this thing is not nearly
# secure enough to be open to the world
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment