kgb-bot-1.60/000077500000000000000000000000001454442667400130055ustar00rootroot00000000000000kgb-bot-1.60/Build.PL000066400000000000000000000060461454442667400143070ustar00rootroot00000000000000package main; use strict; use warnings; use lib qw(privinc); use My::Builder; use utf8; my $json_rpc_client_module = eval { require JSON::RPC::Client } ? 'JSON::RPC::Client' : 'JSON::RPC::Legacy::Client'; my $builder = My::Builder->new( dist_name => 'App-KGB', dist_version_from => 'lib/App/KGB.pm', dist_author => [ "KGB authors. See the copyright notices in individual files" ], license => 'GPL_2', create_license => 1, configure_requires => { 'Module::Build' => '0.40', perl => '5.010', }, test_requires => { autodie => 0, 'Dpkg::Version' => 0, 'File::Remove' => 0, 'Git' => 0, perl => '5.010', 'SVN::Core' => 0, 'SVN::Fs' => 0, 'SVN::Repos' => 0, 'Test::Compile' => 0, 'Test::Differences' => 0, 'Test::Exception' => 0, 'Test::Perl::Critic' => 0, 'Test::Pod::Coverage' => 0, 'Test::Pod' => 0, 'Test::Simple' => '0.92', 'YAML' => 0, }, requires => { perl => '5.010', 'Class::Accessor' => 0, 'DBD::Pg' => 0, 'Digest::SHA' => 0, 'DirHandle' => 0, 'File::Touch' => 0, 'Git' => 0, 'IPC::Run' => 0, 'IPC::System::Simple' => 0, 'List::MoreUtils' => 0, 'JSON::XS' => 0, $json_rpc_client_module => 0, 'Net::IP' => 0, 'POE' => 0, 'POE::Component::IRC' => '5.56', 'POE::Component::Server::SOAP' => 0, 'Proc::PID::File' => 0, 'SOAP::Lite' => 0, 'SVN::Core' => 0, 'SVN::Fs' => 0, 'SVN::Repos' => 0, 'Schedule::RateLimiter' => 0, 'Text::Glob' => 0, 'Time::Piece' => 0, 'WWW::Shorten' => 0, 'YAML' => 0, }, bindoc_dirs => [qw(script sbin)], install_path => { sbin => '/usr/sbin', etc => 'etc' }, sbin_files => { 'script/kgb-bot' => 'sbin/kgb-bot', 'script/kgb-add-project' => 'sbin/kgb-add-project', 'script/kgb-split-config' => 'sbin/kgb-split-config', }, etc_files => { 'etc/kgb.conf' => 'etc/kgb-bot/kgb.conf' }, man_files => { 'man5/*' => 'man5/' }, script_files => [ 'script/kgb-client', 'script/kgb-ci-report' ], no_index => { directory => [ 'privinc' ], }, ); $builder->add_build_element('sbin'); $builder->add_build_element('etc'); $builder->add_build_element('man'); $builder->create_build_script(); kgb-bot-1.60/Changes000066400000000000000000000713631454442667400143120ustar00rootroot000000000000001.60 2024-01-01 [ Damyan Ivanov ] * Changes: drop round brackets around release dates (Closes: #1057932) [ Antoine Beaupré ] * trickle up error messages in JSON RPC calls. [ gregor herrmann ] * debian/copyright: update copyright holders/years. * Declare compliance with Debian Policy 4.6.2. 1.59 2023-10-30 [ gregor herrmann ] * t/76-webhook-pipeline.t: use status=failed instead of failure to match Gitlab pipeline status (no functional change). [ Martina Ferrari ] * Update my name and email address. [ Damyan Ivanov ] * avoid warning in kgb-ci-report when a package is first tested by the CI prev_status is undefined in such situations * systemd: add Restart=on-failure helps providing the service even after a crash 1.58 2020-11-03 * fix tests to not hard-code merge commit messages 1.57 2020-07-24 * Update tests to changed output in merge messages for Git 2.28.0+. Thanks to Jonathan Nieder for the bug report. (Closes: #965350) 1.56 2020-03-22 [ Iain Lane ] * kgb-bot: Support globs in only_branches. This will allow derivatives to maintain their packages on Salsa, but not announce the changes to their branches to the Debian IRC channels. (Closes: #945015) * kgb-bot: Add only_tag parameter. As with `only_branch`, this will make the bot only announce changes to tags matching the given globs. [ gregor herrmann ] * Update copyright notices. * Add new requirements to Build.PL. 1.55 2019-06-13 [ gregor herrmann ] * fix typo in test diag() [ Damyan Ivanov ] * fix coloring of failed pipelines (Closes: #930450) 1.54 2019-01-03 [ Damyan Ivanov ] * comment out the test client config example of message-template * use_ssl: 0 in the example test server configs [ gregor herrmann ] * script/kgb-bot: use $client_ip->ip in webhook error message like in the debug message. Thanks to James Clarke for the suggestion. [ Damyan Ivanov ] * kgb-bot: convert ::ffff:a.b.c.d to a.b.c.d before looking up client ip in the white list 1.53 2018-10-13 [ Damyan Ivanov ] * drop port: option from default config * add port to the test server IRC config now that 6697 us the default * encode/decode Git directory name when passing it to Git or when reading it from the environment this matters when the directory name is not plain ASCII (Closes: #822375) * auto join: increase NickServ delay to 60 seconds (default is 5) this helps joining +r channels on freenode, where nick server identification takes more than 5 seconds * fix path to scripts in t/critic.t * reorder default notification order, keeping the order of colours the new order is project/module, branch, commit, author, log * Client::Git: strip leading whitespace when parsing the output of 'git status' [ gregor herrmann ] * kgb-bot: human_duration(): also handle case where there are exactly two time parts. Thanks to Mattia Rizzolo for the bug report on IRC. * Declare compliance with Debian Policy 4.2.1. 1.52 2018-09-13 [ gregor herrmann ] * Add some documentation about the webhook configuration to kgb.conf(5). [ Damyan Ivanov ] * kgb-ci-report: avoid counting duplicate source packages in the UDD SQL query * kgb-bot: add support to use_ssl configuration parameter (per network) (defaults to 1) 1.51 2018-06-04 [ Damyan Ivanov ] * kgb-ci-report: avoid boolean evaluation of Dpkg::Version object where a simple existence test is enough (Closes: #900699) 1.50 2018-05-23 [ Martina Ferrari ] * Add merge request title to merge request notifications. * Stop using channel as a unique identifier. This is a big change, as most of the code was assuming a channel name is unique across networks, causing weird issues when adding channels dynamically from a webhook. * Factor out some repetitive code. * The current code was leaving the configuration in a inconsistent state when a channel was dynamically added; now it is done as if it was added to the configuration. * Finally fix the dynamic join problem. [ Damyan Ivanov ] * use get_chanid at one more place instead of hand-crafted concatenation * when complaining of a repo without channels, suggest adding them to the request parameters 1.49 2018-04-29 [ Damyan Ivanov ] * add 'always_squash_outside_dir' webhook option (multiple values) 1.48 2018-04-21 [ Damyan Ivanov ] * add only_branch webhook option * webhook: add (via ...) only when *both* user name and email differs between author and pusher 1.47 2018-04-10 [ Damyan Ivanov ] * webhook/merge request: drop "revision" output and put the action in square brackets * set default params in one place * add shorten_urls webhook parameter, defaults to 1 [ James Clarke ] * webhook: + Better tag deletion messages + Show branch deletions (Closes: #895283) [ Damyan Ivanov ] * fix warning about double "my" in 70-webhook-push.t * fix 52-client-git.t and 53-client-git-merges.t with Git 1.17. (Closes: 894775) [ Colin Finck ] * Git client: Support an "author-via" placeholder in the message template, which shows the author and committer name if both are different. 1.46 2018-03-08 [ Damyan Ivanov ] * webhook/push: add always_squash_branch parameter, defaults to [ 'upstream', 'upstream/master' ] * fix stats counting * bot: reload URL shortening module when the config is changed * document short_url_service in kgb.conf(5) [ James Clarke ] * Use ! rather than # for GitLab merge requests * Use iid rather than global id for merge requests and issues [ gregor herrmann ] * bot: rename "signed-tags" to "signed tags", as in the client. 1.45 2018-03-06 [ Damyan Ivanov ] * point output of '/ctcp source' to salsa * fix short url code after 97033851da793b345f5283fb96897d5f9b55b810 * collect some stats - run time, notification counts * react to !stats and !statsreset * update HOWTO.release * shorten compare URLs 1.44 2018-03-03 [ Damyan Ivanov ] * bot/webhook: shorten git hashes in URLs (as a fallback when URL shortening has problems or is not configured) * webhook: no heuristics when determining which params are arrays * webhook/pipeline: add support for pipeline_only_status URL parameter (multiple values) (Closes: #891870) * webhook: colorize pipeline success/failure in reverse green/red 1.43 2018-03-02 [ Damyan Ivanov ] * improve pipeline notifications * improve commit squash handling 1.42 2018-02-26 [ Martina Ferrari ] * Speed-up KGB joining of channels and setup. Monkey-patch the delayed command dispatcher in PoCO::IRC to ignore flood-prevention measures for high-priority messages (JOIN, MODE, etc), now joins of many channels can be completed in a few seconds. [ Damyan Ivanov ] * webhooks: make use_irc_notices=1 the default, as advertised 1.41 2018-02-24 [ Damyan Ivanov ] * mark not released versions as 'Not Released' to make Test::CPAN::Changes happy * add a test ensuring the current release has an entry in Changes * webhook: fix accounting the `use_irc_notices` option [ gregor herrmann ] * fix a typo in POD 1.40 2018-02-20 [ Damyan Ivanov ] * webhook/push: + fix the compare URL when squashing branch updates + change the default for squash_threshold from 4 to 20 1.39 2018-02-19 [ Damyan Ivanov ] * webhook/push: handle the case when the author is not the person pushing the branch 1.38 2018-02-17 [ Damyan Ivanov ] * webhok/tag_push: + add tag URL + recognize signed tags 1.37 2018-02-16 [ Damyan Ivanov ] * webhooks: support squashing of branch updates 1.36 2018-02-12 [ Damyan Ivanov ] * Fix typo missing tag_push webhook events 1.35 2018-02-12 [ gregor herrmann ] * WWW::Shorten::Debli: use https for deb.li URLs. Thanks to pabs for the pointer. [ Damyan Ivanov ] * use the interpreter running the test to run the test client otherwise the system-wide perl is used, which may be configured (e.g. @INC) quite differently Thanks to Slaven Rezić (RT#108400) * fix comparison of Git version to 2.9.0, when the minor version is greater t» "2.15.0" ge "2.9.0" returns false, because it uses string comparison and "1" is less than "9". * bot: preliminary support for GitLab webhook termination at /webhook/ * bot: let --debug override the config setting * bump copyright years * TestBot: die if the bot exits with non-zero status * bot: + add support for GitLab webhook termination at /webhook/ + add systemd .service file + irc_new_hash: make new entries enter at the top of the list + stop sending /WHO when somebody joins + debug: prepend the line number + fix disabling of colors on use_color=0 * Painter: fix 'item_colors' member name mistake * kgb-ci-report + POD: wrap links in L<>, use https + use https for ci.debian.net + use udd-mirror.debian.net for connecting to UDD + allow running without --kgb-config * tests: allow overriding of bot/client location 1.34 2016-09-26 [ Damyan Ivanov ] * add patch fixing tests in build environments where the current user has no full name (Closes: #769239 -- FTBFS) [ gregor herrmann ] * kgb-client.conf(5): change example shortening service from Metamark to TinyURL, following the example of WWW::Shorten. Metamark is not accepting new URLs anymore. [ Damyan Ivanov ] * also mention cgit in the web-link description * add a new script, kgb-ci-report. used to notify about CI failures * bump years of copyright [ Pierre Schweitzer ] * kgb-client: use login name when the full user name is not available Closes: #772747 * Remove ${{project/}} token from the example multi-line message configuration (already removed from the single-line configuration) Closes: #772749 * Fix multiline message template Closes: #772750 [ Damyan Ivanov ] * TestBot: - when waiting for the PID file to appear, also see if it has any content - close the PID file after reading it * kgb-bot: - add the PID to the "Listening on ..." line in the log - rewrite the PID management code using OO interface of Proc::PID::File. This fixes a rather nasty hardly-reproducible bug causing the PID file to be re-created after being removed, which may fool the tests and make them hang. Closes: #782079 [ gregor herrmann ] * Build.PL: - install new kgb-ci-report script - add DBD::Pg as requirement in Build.PL * Fix some typos in the POD. Thanks to lintian. [ Martina Ferrari ] * App::KGB::Client::ServerRef: - More consistent verbose reporting of server communication. - Add --dry-run option for debugging. - Bug fix: use correct method when sending a commit info with default protocol. * App::KGB::Client: format_message: Don't lose data. When the commit object does not have all the info, it still overwrites data coming from the extra arguments. It meant SVN commits were lacking branch and module information completely. [ gregor herrmann ] * Fix t/52-client-git.t to work with newer git versions as well. Since 2.9.0, git allows merging branches without a common ancestors only when "--allow-unrelated-histories" is passed. This has lead to test failures. Pass the parameter conditionally. 1.33 2014-08-06 * TestBot: set $ENV{USER} to getpwnam($>) to fix discrepancy when running under sudo (as in pbuilder) 1.32 2014-08-04 [ Damyan Ivanov ] * bot: store real path to the pid directory * bot: remove PID file on exit * fix utf-8 locale detection in 50-client.t * TestBot: test helper module for running a real bot for tests * 50-client.t: check real bot output * TestBot: report bot PID when starting/stopping * convert 52-client-git to TestBot * fix detection of common changes path when using msg_template * require File::Remove and Test::Differences for tests * convert 53-client-git-merges.t to TestBot * convert 54-client-git-squash.t to TestBot * convert t/55-client-git-merges-ff.t to TestBot * convert t/56-client-git-ff-merge-2.t to TestBot * convert t/57-client-git-squash-tags.t to TestBot * avoid double-spaces when formatting messages * bot: honour broadcast channels setting when relaying messages too [ gregor herrmann ] * kgb.conf(5): improve documentation for server_addr variable. (Closes: #744689) [ Damyan Ivanov ] * kgb-client: add support for setting Git-specific options via the configuration file/command line * point to client backends for backend-specific configuration options * use encoding 'utf8' --> use utf8 * replace given/when with chained if/elsif/else * missing newline between =items (POD) * update FSF address * bump years of copyrigght * put GPL_2 as license in Build.PL (gpl2 is not recognised anymore) * move gathering of data from new() to _detect_commits * a new internal method, _reset, for resetting the parsed reflog data * use strict and warnings in tests * tests: replace explicit plans with done_testing() * die when the reflog is empty * fix typo in changelog (wheter -> whether), thanks lintian 1.31 2013-08-17 * client: default to using json * remove author-login from default message templates * import dirname in Client.pm * configure test git repositories whether test bot is running or not * remove project from default configuration * update documentation about default message templates * add author_name field for CVS commits * client: decode arguments given to --relay-msg * require JSON::XS instead of plain JSON 1.30 2013-08-09 * bot: fix colorize_change_wrapper 1.29 2013-08-08 * add versions to all modules * ensure strict and warnings are used everywhere 1.28 2013-08-08 [ gregor herrmann ] * client: Fix failure with Safe-2.35. Thanks to Petr Písař for the patch. [ Damyan Ivanov ] * client: detect UTF8 in full author name * git client: add kgb.enable-branch-ff-notification Git option (true by default) for managing fast forward notifications * declare test dependencies in test_requires * client: add --debug option * git client: chomp git-config-determined config file path before usage * replace ~~ (smartmatch) usage. ~~ is deprecated in perl 5.18 * replace given/when usage, declared experimental in perl 5.18 * client: verify config file structures * git client: do not die on unknown ref updates (see #706375) * git client: squash creation if numerous tags (>5 currently) * git client: configurable tag squash threshold/message * client: correct POD about Client->format_message arguments * bot: allow setting of "" color to disable colouring of a given item * bot: use App::KGB::Painter for coloring * bot: add --simulate-color option enabling color codes in the dump file * git client: include tag name in the Tag object created from annotated tags * git client: allow specifying project-id via git-config * t/50-client.t: skip tests with UTF-8 commit messages (subversion) unless C_TYPE is known to use UTF-8. RT#80664 * adapt to newer JSON-RPC which renamed the client module (RT#80666) 1.27 2013-05-29 * client: + --repository option is no longer required + add support for entirely client-constructed notifications + verbose complaint when a message cannot be encoded as JSON + add support for batching messages + Git: include author name in commit information (Debian: #700319) + Git: add support for configuring some settings via git-config + Git: implement commit squashing for large branch updates * bot: + support miltiple relay messages per request + properly handle multi-line relayed messages + add rate limit support to JSON message relay implementation + Fix a problem where authentication was sent too late, due to throttling caused by JOIN commands sent earlier. This change uses the AutoJoin plugin that knows how to interact with NickServID properly. Patch contributed by poco-irc maintainer, Hinrik Orn Sigurdsson. * both: + add support for ${project} substitution in web_link + documentation improvements * building + Add Time::Piece and IPC::Run to Build.PL. + Build.PL: create LICENSE file during `make dist'. 1.26 2013-03-28 * update kgb-client.conf manual with the new options * rework Git branch walking avoids multiple notification about merged commits (Closes Debian bug #698133) * notify even if log message is invalid UTF-8 notification with log of "(log is invalid UTF-8)" is better than no notification at all (Closes Debian bug #691183) 1.25 2012-12-27 * Documentation + client/CVS: mention that CVSROOT is a module + add HOWTO.release to MANIFEST * Internal: + Client/Git: rename _process_commit method to _process_changeset to better describe what it does * Client/Server: + add support for using IRC notices + add support for disabling color * Client: + fix --password option definition + rework configuration to make priority explicit 1.24 2012-11-22 * Documentation: + Document KGB protocol (currently v4 JSON only). + kgb-client.conf(5): add single-line-commit option. + Document web-link configuration via git-config. * Client: + Add a few checks on the configuration file. + Add --man and --help command-line options. + Fix validation of --single-line-commits argument. + Support web-link option via git configuration. * Server: + Avoid responding to senders having .bot. in their hostname. + change default port to 5391. Closes Debian bug #691562 -- port conflict with approx. + kgb-add-project: chown/chmod config (snippet) like kgb.conf. + Use asterisk for web link separator (used also for commit message separator). + Explicitly check and die if included conf file doesn't exist. + Put URL on first line of multi-line notifications. + Put back SVN in requirements now that Module::Build is fixed. See https://rt.cpan.org/Public/Bug/Display.html?id=59593 1.23 2012-10-20 * t/compile*: use Test::Compile::Internal in order to show verbose errors * Server: + add --debug command line switch + replace --config-dir option with 'include:' configuration item add 'include: "/etc/kgb-bot/kgb.conf.d"' to the default config + default pid_dir to /var/run/kgb-bot * Documentation: + add manuals for kgb.conf and kgb-client.conf + pod.t: test documentation in man*/ too + give example for gitweb URL * Client: + show expanded web-link in verbose mode + dump processed configuration in verbose mode + shorten_url: really return plain URL if shortening is not enabled + send_changes: detailed dump in verbose mode + introduce module-and-branch-re setting and deprecate branch-and-module-re-swap 1.22 2012-10-14 * kgb-add-project: document the new --dir option * Add API documentation (JSON-RPC only) * Server: + prepend all IRC strings with a hidden character to avoid addressing + honour --foreground when reloading and don't reopen the log + change the delimiters around web links to make konsole users' life easier + pass --config-dir too on restart + add new kgb-split-config script + refuse to load world-readable configuration files * fix a bug in determining the longest common directory in a change set 1.21 2012-10-11 * Server: + fix exception handling + better error messages * Debli: prepend 'http://deb.li/' to the returned key 1.20 2012-10-11 * kgb-add-project: avoid using 'keys($hashref)' which requires too recent perl * Client: + add --reposotory to synopsis + fix --repository in CVS example + CVS: silence debugging output + WWW:Shorten::Debli implementation (uses deb.li for URL shortening) + determine default repository type from the environment (makes --repository useless) + determine default module from git directory (makes --module redundant for Git) + allow explicit protocol configuration + saving of last contacted server -- in a separate method * Server: + ensure trailing \n in KGB->out + note repository id on internal errors + conf.d/*.conf style configuration + use exceptions for handling argument errors + turn on utf8 mode on STDOUT/ERR + use shorter timestamp representation * Both: + protocol 4 (JSON-RPC) + plain message relaying (Closes: #689641) * some spellchecking 1.19 2012-10-05 * Bot: + add timestamp to log messages + use KGB->out() instead of plain warn() for consistent log messages + tighten auto-responce rate-limit to stop storms in the first screen + silently ignore empty changes + do not crash on internal errors while processing requests * kgb-add-project: sort the channel hashes to make sure "name" is the first key. 1.18 2012-10-05 * bot: fix channel-must-have-a-repository check for broadcast channels 1.17 2012-10-05 * improve wording of web-link description * 50-client.t: support keeping temporary directory * declare POD encoding * additional documentation for web-link * explain status-dir in the sample client config * add support for URL shortening via WWW::Shorten + kgb-client: add libwww-shorten-perl to Recommends * client: add --fake option. Fakes a commit to help testing server connection (Closes: #689540) * bot: introduce broadcast channels which receive notifications from all repositories Closes: #688993 + introduce private repositories * bot: fail if a repository has no associated channels * typo/doc fixes * kgb-add-project: add option to save config back to file 1.16 2012-10-03 * Misc + Typos in documentation fixed * Server + indicate replacement using 'brown' (which should be displayed as low intensity red or something) instead of inverse + add script to add simple projects quickly + call $poe_kernel->has_forked in the child process Makes the reload action of the bot work (Closes: #689018) + reopen logs on reload + create log file in the init script, not in postinst + init script: depend on $network facility and add status option. + init script: add pidfile argument to status option + add bot reload to logrotate configuration * Client + honour 'repository' setting in kgb-client.conf (Closes: 688992) + fix forced single-line commit mode. reported by joeyh, fix by dondelelcaro * Both + Add support for plain web links. No URL shortening yet + Protocol v3 (used by client when extra parameters, e.g. web link need to be sent) + Add CVS support (Closes: #689288) (Mostly in the client, but server needed some changes to drop assumptions that commits always have IDs) 1.15 2011-09-14 * Client: + make File::Touch usage optional, used only when status_dir is present + use single line note for annotated tags + document --status-dir + consistent POD formatting + POD fix for --single-line-commits in synopsis * Server: + fix single line commits with multi-line explaination + move detect_common_dir to App::KGB::Change (as a class method) + no bold revision by default + drop (bold) repository name from the notification * Misc: + fix eg/run-test-bot-dump + My::Builder: make the 'orig' target also provide a (hardlinked) distribution archive * Tests: + initially trim the dump file only if existing + fix single line notification separator + tags are single line too + add tests for decect_common_dir + more extensive tests for debian/patches series some.patch (still passing) 1.14 2011-08-24 * Client: + pass the client instance to the server ref + add an option to keep the last used server in a directory * Server: + do not pre-pad $path_string if it is empty + make the message separator colorizable (and leave gray for now) + avoid calling md5_hex with wide characters * Both: + add support for single line commit notifications * Meta: + add MANIFEST and META.yml to MANIFEST (and the distribution) * Misc + provide examples for running two test bots + provide test client configuration + use sample test client config in tests 1.13 2011-08-13 * bot: add --simulate option * remove dead code * run-test-bot passes arguments to kgb-bot * change the port of the test bot * silence more git jabber during tests * add tests for simulated IRC output 1.12 2011-08-13 * Updated META.* 1.11 Not Released * test creation of brand new, orphan branch * fix: no warnings when commits have no author * bot: log repository on authentication failure * put tag name in changes for plain tags too * bot: always decode parameters 1.10 2011-08-11 [ Daman Ivanov ] * disable indexing of privinc/ * fix a couple of cases of conrdirtional declaration * add a Perl::Critic test for conditional declarations * bot: do not answer back if no answers are configured * rate-lmit autoresponses 1.09 Not Released [ Damyan Ivanov ] * Skip some tests when required SVN::* or Git modules are unavailable * Fix dist_name from App::KGB to App-KGB 1.08 2011-08-05 [ Damyan Ivanov ] * Fix version disparity between App::KGB and kgb-bot 1.07 2011-07-26 [ Damyan Ivanov ] * Client::Git: use --format=raw when describing annotated tags 1.06 2010-12-04 [ gregor herrmann ] * kgb-bot: - fix typo when accessing global config - call polygen_available with full class name [ Damyan Ivanov ] * kgb-bot: drop the asterix prefix from revision number * Makefile: fix (real|dist)clean targets to use ./Build for the real work * App::KGB::Change: + fix typo in POD + make the stringification method public and document it * t/52-client-git.t: when comparing changes, force objects to stringify * MANIFEST.SKIP: add MYMETA.yml * fix typo in Client::Subversion POD 1.05 2010-09-10 * kgb-bot: use File::Which to find polygen binary; split out the polygen-finding function; closes: #593631 * kgb-bot: check existence of polygen binary before using it; closes: #593633 * add gregor to copyright holders * move polygen detection entirely at runtime * any problems in finding polygen binary are logged only when debug is enabled as a counter-measure against remotely-assisted log abuse 1.04 2010-08-03 * use Digest::SHA from core instead of ::SHA1 * remove references to Svn::* from Build.PL Closes: #582739 (by working around #589812) 1.03 2010-04-28 * Synchronized versions of kgb-bot and KGB 1.02 Not Released * Protocol v2 + Adds a new parameter, revision prefix, which is printed plain before the bold commit ID + The default revision prefix is empty ('') + Subversion revision prefix is 'r' 1.01 2009-12-05 * Client: drop branch/module detection if not all changed paths are in the same branch/module 1.00 2009-12-02 * ServerRef: send commit_id as a string * Commit: decode UTF-8 log messages * ServerRef: encode all strings before sending 0.16 2009-11-24 * bot: + print the path information part along the author and revision 0.15 2009-11-07 * bot: + bump years of copyright + make manual page speak about 'kgb-bot', not 'KGB' + out(): this is a class method, do not print the first argument + remove the '_ECHO_' network * Git: + more robust commit parsing + fix describing newly created branches * client: + fail gracefuly when repo type module is not available * tests + support sending test commits to a live running bot when TEST_KGB_BOT_RUNNING is in the environment 0.14 2009-11-02 * Git: fix describing merge commits * bot: replace change flags (A+)... with colors * bot: avoid sending changed files list for commits that don't contain changed files * bot: always detect common changes directory 0.13 2009-11-01 * kgb-bot: fix the code detecting common root for all changes 0.12 2009-10-31 * add a test ensuring that App::KGB and kgb-bot are the same version * client + honor branch and module supplied by commit + make server choice stable within one client call + Git - drop autodie and check for error when calling open() - when describing changes, use App::KGB::Change objects - fix parsing of multi-line log messages - fix reverse commit order on branch updates - special handling of signed/annotated tags - use raw commit logs to detect file additions/removals 0.11 2009-10-26 * move generation of a smart answers to a subroutine * make the autoresponder use polygen * fix typo in an error message 0.10 2009-10-25 * kgb-bot has its own version. no longer pulls the client via App::KGB 0.09 2009-10-24 * print unhandled IRC stuff only when debugging is enabled * implement logging * drop auto-rejoin TODO item (sort of done) * move discovery of sender's net into a subroutine * respond to CTCP requests * implement !version command * MANIFEST.SKIP: also skip blib * make orig target invoke d/rules clean to ensure the tarball is created off a clean tree * test-server.conf: use local irc server for testing test server considers all local users admins * handle both public and private messages kgb-bot-1.60/HOWTO.release000066400000000000000000000005441454442667400152520ustar00rootroot00000000000000Steps for creating new releases =============================== * Bump version in lib/App/KGB.pm * Update Changes and debian/changelog (git-dch) * `make distcheck`, update MANIFEST{,SKIP} as needed. * `make dist' * build/upload for Debian + make orig to get a .orig.tar file in ../ * upload to CPAN + cpan-upload -u USERID ../App-KGB-*.tar.gz kgb-bot-1.60/LICENSE000066400000000000000000000435601454442667400140220ustar00rootroot00000000000000This software is Copyright (c) 2024 by KGB authors. See the copyright notices in individual files. This is free software, licensed under: The GNU General Public License, Version 2, June 1991 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. kgb-bot-1.60/MANIFEST000066400000000000000000000032111454442667400141330ustar00rootroot00000000000000Build.PL Changes eg/kgb-client.conf.sample eg/post-commit eg/run-test-bot-1 eg/run-test-bot-2 eg/run-test-bot-dump eg/setup-test-git-env.sh eg/simple-soap-client eg/simple-soap-server eg/test-client.conf eg/test-server-1.conf eg/test-server-1.conf.d/repos.conf eg/test-server-2.conf etc/kgb.conf HOWTO.release lib/App/KGB.pm lib/App/KGB/API.pm lib/App/KGB/Change.pm lib/App/KGB/Client.pm lib/App/KGB/Client/CVS.pm lib/App/KGB/Client/Fake.pm lib/App/KGB/Client/Git.pm lib/App/KGB/Client/RelayMsg.pm lib/App/KGB/Client/ServerRef.pm lib/App/KGB/Client/Subversion.pm lib/App/KGB/Commit.pm lib/App/KGB/Commit/Tag.pm lib/App/KGB/Painter.pm lib/JSON/RPC/Client/Any.pm lib/WWW/Shorten/Debli.pm LICENSE Makefile man5/kgb-client.conf.pod man5/kgb.conf.pod man7/kgb-protocol.pod MANIFEST This list of files MANIFEST.SKIP META.json META.yml privinc/My/Builder.pm script/kgb-add-project script/kgb-bot script/kgb-ci-report script/kgb-client script/kgb-split-config t/00-compile.t t/00-compile_scripts.t t/00-compile_shell_scripts.t t/30-bot-changes.t t/50-client.t t/51-client_branch_module.t t/52-client-git.t t/53-client-git-merges.t t/54-client-git-squash.t t/55-client-git-merges-ff.t t/56-client-git-ff-merge-2.t t/57-client-git-squash-tags.t t/58-client-git-unicode.t t/70-webhook-push.t t/71-webhook-push_tag.t t/72-webhook-wiki_page.t t/73-webhook-issue.t t/74-webhook-notes.t t/75-webhook-merge-request.t t/76-webhook-pipeline.t t/77-webhook-build.t t/78-webhook-push-squash.t t/79-webhook-push-author.t t/80-webhook-glob-push.t t/81-webhook-push-tag-only-tag.t t/changes.t t/critic.t t/perlcriticrc t/pod-coverage.t t/pod.t t/TestBot.pm t/WWW/Shorten/DummyShortener.pm TODO kgb-bot-1.60/MANIFEST.SKIP000066400000000000000000000001441454442667400147020ustar00rootroot00000000000000^debian/ \.git \.svn ^_build ^blib ^Build$ MANIFEST.bak ^MYMETA.yml$ ^MYMETA\.json$ ^.pc/ \.*\.swp$ kgb-bot-1.60/META.json000066400000000000000000000045051454442667400144320ustar00rootroot00000000000000{ "abstract" : "collaborative IRC helper", "author" : [ "KGB authors. See the copyright notices in individual files" ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4234", "license" : [ "gpl_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "App-KGB", "no_index" : { "directory" : [ "privinc" ] }, "prereqs" : { "configure" : { "requires" : { "Module::Build" : "0.40", "perl" : "5.010" } }, "runtime" : { "requires" : { "Class::Accessor" : "0", "DBD::Pg" : "0", "Digest::SHA" : "0", "DirHandle" : "0", "File::Touch" : "0", "Git" : "0", "IPC::Run" : "0", "IPC::System::Simple" : "0", "JSON::RPC::Legacy::Client" : "0", "JSON::XS" : "0", "List::MoreUtils" : "0", "Net::IP" : "0", "POE" : "0", "POE::Component::IRC" : "5.56", "POE::Component::Server::SOAP" : "0", "Proc::PID::File" : "0", "SOAP::Lite" : "0", "SVN::Core" : "0", "SVN::Fs" : "0", "SVN::Repos" : "0", "Schedule::RateLimiter" : "0", "Text::Glob" : "0", "Time::Piece" : "0", "WWW::Shorten" : "0", "YAML" : "0", "perl" : "5.010" } }, "test" : { "requires" : { "Dpkg::Version" : "0", "File::Remove" : "0", "Git" : "0", "SVN::Core" : "0", "SVN::Fs" : "0", "SVN::Repos" : "0", "Test::Compile" : "0", "Test::Differences" : "0", "Test::Exception" : "0", "Test::Perl::Critic" : "0", "Test::Pod" : "0", "Test::Pod::Coverage" : "0", "Test::Simple" : "0.92", "YAML" : "0", "autodie" : "0", "perl" : "5.010" } } }, "release_status" : "stable", "resources" : { "license" : [ "http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt" ] }, "version" : "1.60", "x_serialization_backend" : "JSON::PP version 4.07" } kgb-bot-1.60/META.yml000066400000000000000000000026261454442667400142640ustar00rootroot00000000000000--- abstract: 'collaborative IRC helper' author: - 'KGB authors. See the copyright notices in individual files' build_requires: Dpkg::Version: '0' File::Remove: '0' Git: '0' SVN::Core: '0' SVN::Fs: '0' SVN::Repos: '0' Test::Compile: '0' Test::Differences: '0' Test::Exception: '0' Test::Perl::Critic: '0' Test::Pod: '0' Test::Pod::Coverage: '0' Test::Simple: '0.92' YAML: '0' autodie: '0' perl: '5.010' configure_requires: Module::Build: '0.40' perl: '5.010' dynamic_config: 1 generated_by: 'Module::Build version 0.4234, CPAN::Meta::Converter version 2.150010' license: gpl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: App-KGB no_index: directory: - privinc requires: Class::Accessor: '0' DBD::Pg: '0' Digest::SHA: '0' DirHandle: '0' File::Touch: '0' Git: '0' IPC::Run: '0' IPC::System::Simple: '0' JSON::RPC::Legacy::Client: '0' JSON::XS: '0' List::MoreUtils: '0' Net::IP: '0' POE: '0' POE::Component::IRC: '5.56' POE::Component::Server::SOAP: '0' Proc::PID::File: '0' SOAP::Lite: '0' SVN::Core: '0' SVN::Fs: '0' SVN::Repos: '0' Schedule::RateLimiter: '0' Text::Glob: '0' Time::Piece: '0' WWW::Shorten: '0' YAML: '0' perl: '5.010' resources: license: http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt version: '1.60' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' kgb-bot-1.60/Makefile000066400000000000000000000006451454442667400144520ustar00rootroot00000000000000#!/usr/bin/make -f PERL ?= /usr/bin/perl Build: Build.PL $(PERL) $< all: build build install test manifest distcheck: Build ./Build $@ orig: distclean [ ! -e debian/rules ] || $(MAKE) -f debian/rules clean $(MAKE) Build ./Build $@ dist: manifest distcheck ./Build $@ clean: [ ! -e Build ] || ./Build $@ realclean distclean: [ ! -e Build ] || ./Build $@ rm -f MANIFEST.bak App-KGB-*.*.tar.gz # vim: noet kgb-bot-1.60/TODO000066400000000000000000000043551454442667400135040ustar00rootroot00000000000000* split kgb-bot into manageable modules * start a real test bot for automated tests - this is now possible via eg/start-test-bot-[12] and 'TEST_KGB_BOT_RUNNING=1 make test' even if useful for local testing the results aren't verified via t/*.t * write tests for CVS client * watch file broken; depending on the UA, alioth replies with "406 Not Acceptable" * admin/sync -- needs a plan Plan A ====== - we need a system which would allow individual instances' admins to update some central configuration store, which is both encrypted and signed. - that central store could be fetched by the bots regularly, the signature verified, and then the changes applied. - the central storage could be on alioth, but the signing should be done remotely somehow (who wants to upload her secret hey to alioth? :)) there could be a tool that automates the signing process (download from alioth, start $EDITOR or add config from command line, sign, upload) - the bots need to be given a keyring with trusted keys, whose signatures they recognise Pros: - powerful - possible addition/modification and removal of project - full encryption end-to-end Cons: - GPG integration in the bot - complex configuraion retrieval - changes need time to propagate - non-trivial creation of changes Plan B ====== - bots recognize a new message for adding projects the message is accompanied with a hash over its contents, the timestamp of the sender, and a shared secret (uses the current json protocol implementation, but with another secret) - any of the admins wanting to add project would run a tool which connects with all the bots sending them the signed message Pros: - relatively simple - instant update Cons: - no encryption - only addition of projects (can be addressed by creating another message for project deletion, and assuming that messages for existing projects replace their configuration) Plan C ====== - do nothing. We managed somehow to maintain the service by hand, only with kgb-add-project Pros: - requires no effort Cons: - requires small effort (×3) every now and then * (wishlist) Immplement a command to make the bot re-join #channels. kgb-bot-1.60/eg/000077500000000000000000000000001454442667400134005ustar00rootroot00000000000000kgb-bot-1.60/eg/kgb-client.conf.sample000066400000000000000000000035501454442667400175510ustar00rootroot00000000000000--- # repo-id is mandatory repo-id: foo # optional list of regular expressions for matching branch and module name each # entry is matched against the changed path, $1 is supposed to be the branch # name, $2 - the module (package) name # forward slashes are escaped, so no special treatment is needed here # the sample is taken from pkg-perl SVN repository, which is Layout 2 (all # trunks under trunk/ and has a special place for applications and # almost-removed stuff) branch-and-module-re: - "/(trunk|tags|apps|attic)/([^/]+)" - "/branches/([^/]+)/([^/]+)" # for layout 1 package -> trunk/branches/tags) naturally the package name comes # into $1 and the branch - into $2. To remedy the situation, use the other # variant: # module-and-branch-re: # - "/packages/([^/]+)/branches/([^/]+)" # - "/packages/([^/]+)/(?:trunk|tags)/([^/]+)" # # some global parameters can be set for all servers password: "very secret" timeout: 15 # also, a single server can be defined with 'uri' # uri: htp://somewhere/ # or, a failover group of servers can be defined servers: - uri: http://localhost:9999/ timeout: 5 # no point in waiting longer for localhost - uri: http://remotehost:9999/ password: "overrides the global one" # status-dir is used to store the last successfully contacted server # this information is used later in order to try to contact the same server # again (if later contact is within some not very big time frame) status-dir: /var/cache/kgb/client-status # a commit URL template to send to the server # ${module}, ${branch} and ${commit} are replaced with the data from the commit # Examples: # "http://svn.debian.org/viewvc/kgb?view=revision&revision=${commit}" # "http://git.debian.org/?p=our-project/${module}.git;a=commitdiff;h=${commit}" web-link: ~ # An optional URL shortening service # see WWW::Shorten manual for the list of supported services short-url-service: ~ kgb-bot-1.60/eg/post-commit000066400000000000000000000022261454442667400156000ustar00rootroot00000000000000#!/bin/sh # vim: ts=4:sw=4:et:ai:sts=4 # # KGB - an IRC bot helping collaboration # Copyright © 2008 Martina Ferrari # # This program is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # # This program is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. REPOS="$1" REV="$2" BOT="`dirname "$0"`"/KGB/script/kgb-client URI="http://localhost:9999/" REPO_ID="`echo "$REPOS" | sed 's/-/_/g; s#^.*\(/srv/svn.debian.org\|\)/svn/\(.\+\)$#\2#; s#/*$##'`" PASSWORD="secret" #"$BOT" --uri "$URI" --repo-id "$REPO_ID" --password "$PASSWORD" "$REPOS" "$REV" "$BOT" --conf /path/to/client.conf "$REPOS" "$REV" kgb-bot-1.60/eg/run-test-bot-1000077500000000000000000000002051454442667400160240ustar00rootroot00000000000000#!/bin/sh set -e PERL5LIB=lib script/kgb-bot --foreground --config eg/test-server-1.conf --config-dir eg/test-server-1.conf.d "$@" kgb-bot-1.60/eg/run-test-bot-2000077500000000000000000000001401454442667400160230ustar00rootroot00000000000000#!/bin/sh set -e PERL5LIB=lib script/kgb-bot --foreground --config eg/test-server-2.conf "$@" kgb-bot-1.60/eg/run-test-bot-dump000077500000000000000000000000721454442667400166330ustar00rootroot00000000000000#!/bin/sh set -e exec eg/run-test-bot-1 --simulate dump kgb-bot-1.60/eg/setup-test-git-env.sh000077500000000000000000000016111454442667400174220ustar00rootroot00000000000000#!/bin/sh set -e set -u ROOT=$PWD mkdir $ROOT/git-test mkdir $ROOT/git-test/repo.git cd $ROOT/git-test/repo.git git init --bare cat < $ROOT/git-test/repo.git/hooks/post-receive #!/bin/sh tee -a $ROOT/git-test/reflog | PERL5LIB=$ROOT/lib $ROOT/script/kgb-client --repository git --uri http://localhost:9999 --pass "truely secret" --repo-id test --git-reflog - EOF chmod 0755 $ROOT/git-test/repo.git/hooks/post-receive mkdir $ROOT/git-test/work cd $ROOT/git-test/work echo "testing" > a git init git add a git commit -m "initial import" git remote add origin file://$ROOT/git-test/repo.git git config --add branch.master.remote origin git config --add branch.master.merge refs/heads/master git push echo "more testing" > b echo "twisted testing" > a git add . git commit -m 'some modifications' echo "third file" > c git add . git commit -m 'short note followed by a longer thing' git push kgb-bot-1.60/eg/simple-soap-client000077500000000000000000000005031454442667400170310ustar00rootroot00000000000000#!/usr/bin/perl use warnings; use strict; use utf8; use SOAP::Lite; my $s=SOAP::Lite->new( uri=>"http://localhost:12700", proxy=>"http://localhost:12700?session=Test", ); my $som = $s->commit(); die 'SOAP FAULT: ', $som->fault->{faultstring}, "\n", $som->fault->{detail}, "\n" if $som->fault; print $som; kgb-bot-1.60/eg/simple-soap-server000077500000000000000000000025131454442667400170640ustar00rootroot00000000000000#!/usr/bin/perl use utf8; use strict; use warnings; use POE; BEGIN { package POE::Component::Server::SOAP; use constant DEBUG=>2; } use POE::Component::Server::SOAP; my $my_name = 'Test'; POE::Component::Server::SOAP->new( ALIAS => "$my_name-SOAP", ADDRESS => '127.0.0.1', PORT => 12700, HOSTNAME => 'localhost', ); POE::Session->create( inline_states => { _start => \&setup_service, _stop => \&shutdown_service, soap_commit => \&do_commit, }, # options=>{trace=>1,debug=>1}, ); POE::Kernel->run; exit 0; sub setup_service { my $kernel = $_[KERNEL]; $kernel->alias_set($my_name) == 0 or die "Can't register alias Test\n"; $kernel->post("$my_name-SOAP" => 'ADDMETHOD', $my_name => 'soap_commit', $my_name => 'commit', ); undef; } sub shutdown_service { my $kernel = $_[KERNEL]; my $session = $_[SESSION]->ID(); warn "_stop \@session $session\n"; $kernel->post(SOAP => 'DELSERVICE', $my_name); } sub do_commit { my $kernel = $_[KERNEL]; my $response = $_[ARG0]; $response->content('OK'); $kernel->post($_[SENDER] => 'DONE', $response ); return; $kernel->post($_[SENDER], 'FAULT', $response, $SOAP::Constants::FAULT_CLIENT, 'Bad request', 'commit not implemented'); return 1; } kgb-bot-1.60/eg/test-client.conf000066400000000000000000000022171454442667400165040ustar00rootroot00000000000000--- repo-id: test branch-and-module-re: - "/(trunk|tags|apps|attic)/([^/]+)" - "/branches/([^/]+)/([^/]+)" web-link: "http://scm.host.org/${module}/${branch}/?commit=${commit}" use-irc-notices: 0 use-color: 1 password: "truely secret" timeout: 15 servers: - uri: http://localhost:9998/ - uri: http://localhost:9997/ # Custom notification formats activate all-in-client function. # When enabled, all message formatting is done on client side # and the result is given to the server for relaying on IRC. # # The substitutions are in the following format: # ${
{}}
# 
 and  are optional and are included in the result only if 
# has a value
#
# Examples:
#
# single-line notifications
#message-template: "${{author-name} }${({author-login})}${ {branch}}${ {commit}}${ {project}/}${{module}}${ {changes}}${ {log-first-line}}${ * {web-link}}"
# multi-line notifications
#message-template: "${{author-name} }${({author-login})}${ {branch}}${ {commit}}${ {project}/}${{module}}${ {changes}}${ * {web-link}}${\n{log}}"

# batch notifications in series to lower transmit overhead
# this will become default at some point
batch-messages: 1
kgb-bot-1.60/eg/test-server-1.conf000066400000000000000000000010261454442667400166670ustar00rootroot00000000000000# vim: filetype=yaml
---
soap:
  server_addr: 127.0.0.1
  server_port: 9998
  service_name: KGB
smart_answers:
  - "I won't speak with you!"
  - "Do not disturb!"
  - "Leave me alone, I am buzy!"
smart_answers_polygen: 1
admins:
  - '*!*@localhost'
pid_dir: .
# anything less is rejected
min_protocol_ver: 1
# we don't want any colors when testing
colors:
 repository: ""
 revision: ""
 author: ""
 branch: ""
 module: ""
 path: ""
debug: 0
include: "eg/test-server-1.conf.d"
webhook:
 enabled: 1
 allowed_networks:
  - 127/8
  - ::1
kgb-bot-1.60/eg/test-server-1.conf.d/000077500000000000000000000000001454442667400171675ustar00rootroot00000000000000kgb-bot-1.60/eg/test-server-1.conf.d/repos.conf000066400000000000000000000005001454442667400211610ustar00rootroot00000000000000# vim: filetype=yaml
---
repositories:
  # just a name to identify it
  test:
    # needs to be the same on the client
    password: "truely secret"
networks:
  local:
    nick: KGB
    server: localhost
    port: 6667
    use_ssl: 0
    flood: 1
channels:
  - name: '#test'
    network: 'local'
    repos:
      - test
kgb-bot-1.60/eg/test-server-2.conf000066400000000000000000000014261454442667400166740ustar00rootroot00000000000000# vim: filetype=yaml
---
soap:
  server_addr: 127.0.0.1
  server_port: 9997
  service_name: KGB
repositories:
  # just a name to identify it
  test:
    # needs to be the same on the client
    password: "truely secret"
# Some witty answer for people that talk to the bot
smart_answers:
  - "I won't speak with you!"
  - "Do not disturb!"
  - "Leave me alone, I am buzy!"
smart_answers_polygen: 1
admins:
  - '*!*@localhost'
networks:
  local:
    nick: KGB-1
    server: localhost
    port: 6667
    use_ssl: 0
    flood: 1
channels:
  - name: '#test'
    network: 'local'
    repos:
      - test
pid_dir: .
# anything less is rejected
min_protocol_ver: 1
# we don't want any colors when testing
colors:
 repository: ""
 revision: ""
 author: ""
 branch: ""
 module: ""
 path: ""
debug: 0
kgb-bot-1.60/etc/000077500000000000000000000000001454442667400135605ustar00rootroot00000000000000kgb-bot-1.60/etc/kgb.conf000066400000000000000000000033251454442667400151750ustar00rootroot00000000000000# vim: filetype=yaml
---
soap:
  server_addr: 127.0.0.1
  server_port: 5391
  service_name: KGB
queue_limit: 150
log_file: "/var/log/kgb-bot.log"
include: "/etc/kgb-bot/kgb.conf.d"
repositories:
  # just a name to identify it
  foo:
    # needs to be the same on the client
    password: ~
    # private repositories aren't announced to broadcast channels
    # private: yes
# Some witty answer for people that talk to the bot
#smart_answers:
#  - "I won't speak with you!"
#  - "Do not disturb!"
#  - "Leave me alone, I am buzy!"
# Admins are allowed some special !commands (currently only !version)
#admins:
#  - some!irc@mask
#  - some!other@host
networks:
  freenode:
    nick: KGB
    ircname: KGB bot
    username: kgb
    password: ~
    nickserv_password: ~
    server: irc.freenode.net
channels:
# a broadcast channel
  - name: '#commits'
    network: freenode
    broadcast: yes
# a channel, tied to one or several repositories
#  - name: '#foo'
#    network: freenode
#    repos:
#      - foo
#    # Can also be set per-channel
#    #smart_answers:
#    #  - "I'm in ur channel, watching ur commits!"
#    #  - "I am not listening"
#    #  - "Shut up! I am buzy watching you."
pid_dir: /var/run/kgb-bot
# anything less is rejected
min_protocol_ver: 1
# default colors:
# colors:
#  repository: bold
#  revision: bold
#  author: green
#  branch: brown
#  module: purple
#  path: teal
#  addition: green
#  modification: teal
#  deletion: "bold red"
#  replacement: reverse
#  prop_change: underline
#  web: silver
# you can combine them like "bold red" (ouch!)
# available colors: black, navy, green, red, brown, purple, orange, yellow,
#  lime, teal, aqua, blue, fuchsia, gray, silver, white
# available modifiers: bold underline reverse
kgb-bot-1.60/lib/000077500000000000000000000000001454442667400135535ustar00rootroot00000000000000kgb-bot-1.60/lib/App/000077500000000000000000000000001454442667400142735ustar00rootroot00000000000000kgb-bot-1.60/lib/App/KGB.pm000066400000000000000000000046341454442667400152430ustar00rootroot00000000000000# vim: ts=4:sw=4:et:ai:sts=4
#
# KGB - an IRC bot helping collaboration
# Copyright © 2008 Martina Ferrari
# Copyright © 2009 Damyan Ivanov
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

package App::KGB;

use strict;
use warnings;

=encoding UTF-8

=head1 NAME

App::KGB - collaborative IRC helper

=cut

our $VERSION = '1.60';

=head1 DESCRIPTION

B is a helper aimed at people working together using version control
systems and IRC. It has two parts:

=over

=item server, L

A daemon listening for commit notifications that relays them to IRC.

=item client, L, L

Hooks into the version control system and sends commit notifications to the
daemon.

=back

=head2 SUPPORTED VERSION CONTROL SYSTEMS

=over

=item Git

=item Subversion

=back

=head1 SEE ALSO

=over

=item L

=item L

=item L

=back

=head1 AUTHOR

=over

=item Martina Ferrari L

=item Damyan Ivanov L

=back

=head1 LICENSE

Copyright (C) 2008 Martina Ferrari
Copyright (C) 2008-2009 Damyan Ivanov

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

=cut

1;
kgb-bot-1.60/lib/App/KGB/000077500000000000000000000000001454442667400146765ustar00rootroot00000000000000kgb-bot-1.60/lib/App/KGB/API.pm000066400000000000000000000066661454442667400156630ustar00rootroot00000000000000# vim: ts=4:sw=4:et:ai:sts=4
#
# KGB - an IRC bot helping collaboration
# Copyright © 2012 Damyan Ivanov
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

package App::KGB::API;

use strict;
use warnings;

our $VERSION = 4;

1;

__END__

=head1 NAME

App::KGB::API -- KGB bot API documentation

=head1 VERSION 4 (JSON)

=head2 General, authentication

Version 4 uses JSON-RPC as described in
L with one extension. Since all
requests are authenticated, two HTTP headers need to be included:

=over

=item X-KGB-Project: project-name

=item X-KGB-Auth: hash

=back

The project name is the string identifying the project on the server side, and
the hash is the hexadecimal representation of the SHA-1 hash calculated over
the following data:

=over

=item Project password

This is the shared password known to the client and the server.

=item project-name

=item request-text

This is the JSON-encoded request text. The same that is sent in the HTTP body.

=back

=head2 Commit notification

Request is a JSON-RPC call to a method called B with a single
argument, which is a map with the following possible keys:

=over

=item repo_id I

=item rev_prefix I

Usually C for Subversion commits

=item commit_id I

Subversion revision, Git hash or just empty (for CVS).

=item changes I

A list of changes, encoded as strings. It is simple file name prepended with
C<(A)> for added, C<(M)> (or nothing) for modified and C<(D)> for deleted. See
L.

=item commit_log I

=item author I

=item branch I

=item module I

=item extra I

A map with extra information. Currently C is the only member that the
server recognises.

=back

=head2 Plain message relay

The message relay calls are to the B method, with the only
argument the message to be relayed.

=head1 SEE ALSO

L, L

=head1 AUTHOR

=over

=item Damyan Ivanov L

=back

=head1 COPYRIGHT & LICENSE

Copyright (C) 2012 Damyan Ivanov

This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
details.

You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

=cut
kgb-bot-1.60/lib/App/KGB/Change.pm000066400000000000000000000124231454442667400164230ustar00rootroot00000000000000# vim: ts=4:sw=4:et:ai:sts=4
#
# KGB - an IRC bot helping collaboration
# Copyright © 2008 Martina Ferrari
# Copyright © 2009 Damyan Ivanov
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
package App::KGB::Change;

use strict;
use warnings;

our $VERSION = 1.22;

use File::Basename qw(dirname);

=head1 NAME

App::KGB::Change - a single file change

=head1 SYNOPSIS

    my $c = App::KGB::Change->new(
        { action => "M", prop_change => 1, path => "/there" } );

    print $c;

    my $c = App::KGB::Change->new("(M+)/there");

=head1 DESCRIPTION

B encapsulates a single path change from a given change set
(or commit).

B overloads the "" operator in order to provide a default
string representation of changes.

=head1 FIELDS

=over

=item B (B)

The action performed on the item. Possible values are:

=over

=item B

The path was modified.

=item B

The path was added.

=item B

The path was deleted.

=item B

The path was replaced.

=back

=item path (B)

The path that was changed.

=item prop_change

Boolean. Indicated that some properties of the path, not the content were
changed.

=back

=cut

use base 'Class::Accessor::Fast';
__PACKAGE__->mk_accessors(qw( action prop_change path ));

use Carp qw(confess);

=head1 CONSTRUCTOR

=head2 new ( { I } )

More-or-less standard constructor.

It can take a hashref with keys all the field names (See L<|FIELDS>).

Or, it can take a single string, which is de-composed into components.

See L<|SYNOPSIS> for examples.

=cut

sub new {
    my $class = shift;
    my $self  = $class->SUPER::new();

    my $h = shift;
    if ( ref($h) ) {
        defined( $self->action( delete $h->{action} ) )
            or confess "'action' is required";
        defined( $self->path( delete $h->{path} ) )
            or confess "'path' is required";
        $self->prop_change( delete $h->{prop_change} );
    }
    else {
        my ( $a, $pc, $p ) = $h =~ /^(?:\(([MADR])?(\+)?\))?(.+)$/
            or confess "'$h' is not recognized as a change string";
        $self->action( $a //= 'M' );
        $self->prop_change( defined $pc );
        $self->path($p);
    }

    return $self;
}

=head1 METHODS

=over

=item as_string()

Return a string representation of the change. Used by the ""  overload. The resulting string is suitable for feeding the L<|new> constructor if needed.

=cut

use overload '""' => \&as_string;

sub as_string {
    my $c  = shift;
    my $a  = $c->action;
    my $pc = $c->prop_change ? '+' : '';
    my $p  = $c->path;

    my $text = '';

    # ignore flags for modifications (unless there is also a property change)
    $text = "($a$pc)" if $a ne 'M' or $pc;
    $p =~ s,^/,,;    # strip leading slash from paths
    $text .= $p;
    return $text;
}

=back

=head1 CLASS METHODS

=over

=item detect_common_dir(C)

Given an arrayref of changes (instances of APP::KGB::Change), detects the
longest path that is common to all of them. All the changes' paths are trimmed
from the common part.

Example:

 foo/b
 foo/x
 foo/bar/a

would return 'foo' and the paths would be trimmed to

 b
 x
 bar/a

=cut

sub detect_common_dir {
    my $self = shift;
    my $changes = shift;

    return '' if @$changes < 2;    # common dir concept only meaningful for
                                   # more than one path

    my %dirs;
    my %most_dirs;
    for my $c (@$changes) {
        my $path = $c->path;

        # we need to pretend the paths are absolute, because otherwise
        # paths like "a" and "." will be treated as being of the same
        # deepness, while "." is really the parent of "a"
        # the leading "/" is stripped before further processing
        $path = "/$path" unless $path =~ m{^/};
        my $dir = dirname($path);
        $dirs{$dir}++;
        while (1) {
            $most_dirs{$dir}++;
            my $ndir = dirname($dir);
            last if $ndir eq $dir;    # reached the root?
            $dir = $ndir;
        }
    }

    my $topdir = '';
    my $max    = 0;

    # we want to print the common root of all the changed files and say
    # "foo/bar (42 files changed)"

    for my $dirpath ( keys %most_dirs ) {
        if (   $max < $most_dirs{$dirpath}
            or $max == $most_dirs{$dirpath}
            and length($topdir) < length($dirpath) )
        {
            $max    = $most_dirs{$dirpath};
            $topdir = $dirpath;
        }
    }

    # remove the artificial leading slash
    $topdir =~ s{^/}{};

    for (@$changes) {
        my $p = $_->path;
        $p =~ s{^/$topdir/?}{}x
            or $p =~ s{^$topdir/?}{};
        $_->path($p);
    }

    return $topdir;
}

=back

=cut

1;
kgb-bot-1.60/lib/App/KGB/Client.pm000066400000000000000000000716341454442667400164650ustar00rootroot00000000000000package App::KGB::Client;
use utf8;
require v5.10.0;

use feature 'switch';
use strict;
use warnings;

our $VERSION = '1.34';

# vim: ts=4:sw=4:et:ai:sts=4
#
# KGB - an IRC bot helping collaboration
# Copyright © 2008 Martina Ferrari
# Copyright © 2009,2010,2011,2012,2013 Damyan Ivanov
# Copyright © 2018 Colin Finck 
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

=head1 NAME

App::KGB::Client - relay commits to KGB servers

=head1 SYNOPSIS

    use App::KGB::Client;
    my $client = App::KGB::Client(  );
    $client->run;

=head1 DESCRIPTION

B is the backend behind L. It handles
the repository-independent parts of sending the notifications to the KGB server,
L. Details about extracting change from commits, branches and
modules is done by sub-classes specific to the version control system in use.

=head1 CONFIGURATION

The following parameters are accepted in the constructor:

=over

=item B I

Short repository identifier. Will be used for identifying the repository to the
KGB daemon, which will also use this for IRC notifications. B.

=item B I

URI of the KGB server. Something like C. B
either as a top-level parameter or as a sub-parameter of B array.

=item B I

URI of the SOAP proxy. If not given, it is the value of the B option, with
C added.

=item B I

Password for authentication to the KGB server. B either as a
top-level parameter or as a sub-parameter of B array.

=item B I

Timeout for server communication. Default is 15 seconds, as we want instant IRC
and commit response.

=item B

An array of servers, each an instance of L class.

When several servers are configured, the list is shuffled and then the servers
are tried one after another until a successful request is done, or the list is
exhausted, in which case an exception is thrown.

When shuffling, preference is added to the last server used by the client, or
by other clients (given C is configured).

=item B

If true, the notifications are sent as a batch in one request to the server.
Useful with VCS that send many changes a time (e.g. Git).

Defaults to false, but will be changed later after some grace period for server
upgrade.

=item B

A list of regular expressions (simple strings, not L objects) that serve
for detection of branch and module of commits. Each item from the list is tried
in turn, until an item is found that matches all the paths that were modified
by the commit. Regular expressions must have two captures: the first one giving
the branch name, and the second one giving the module name.

All the paths that were modified by the commit must resolve to the same branch
and module in order for the branch and module to be transmitted to the KGB
server.

    Example: ^/(trunk)/([^/]+)/
             # /trunk/module/file
             ^/branches/([^/]+)/([^/]+)/
             # /branches/test/module/file

=item B

Same as B, but captures module name first and branch name second.

    Example: ^/branches/([^/]+)/([^/]+)/
             # /branches/test/module/file

=item B

When most of the development is in one branch, transmitting it to the KGB
server and seeing it on IRC all the time can be annoying. Therefore, if you
define B, and a given commit is in a branch with that name, the
branch name is not transmitted to the server. Module name is still transmitted.

=item B

Forces explicit module name, overriding the branch and module detection. Useful
in Git-hosted sub-projects that want to share single configuration file, but
still want module indication in notifications.

=item B I

Request different modes of commit message processing:

=over

=item I

No processing is done. The commit message is printed as was given, with each
line in a separate IRC message, blank lines omitted. This is the only possible
behaviour in versions before 1.14.

=item I

Only the first line is sent to IRC, regardless of whether it is followed by a
blank line or not.

=item I

If the first line is followed by an empty line, only the first line is sent to
IRC and the rest is ignored. This is the default since version 1.14.

=back

=item B

If true signals the server that it should use IRC notices instead of regular
messages. Use this if regular messages are too distracting for your channel.

=item B

If true (the default) signals the server that it should use colors for commit
notifications.

=item B

Specifies a directory to store information about the last server contacted
successfully. The client would touch files in that directory after successful
completion of a notification with remote server.

Later, when asked to do another notification, the client would start from the
most recently contacted server. If that was contacted too far in the past, the
information in the directory is ignored and a random server is picked, as
usual.

=item B

Print diagnostic information.

=item B I

Use specified protocol version. If C (the default), the version of the
protocol C<2>, unless B is also given, in which case protocol version
C<3> is default;

=item B I