summaryrefslogtreecommitdiffstats
path: root/extensions/PhabBugz/bin
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2017-12-05 15:16:31 +0100
committerDylan William Hardison <dylan@hardison.net>2017-12-05 15:17:21 +0100
commit060d4fa6dd6e98ed45381ddf1e9b9ca2407ab3b3 (patch)
treed662bdbe13a951299930d45fa69cd20e4c47356b /extensions/PhabBugz/bin
parent83bc5b8c30a68203bc073b82be06585b7b6bd799 (diff)
downloadbugzilla-060d4fa6dd6e98ed45381ddf1e9b9ca2407ab3b3.tar.gz
bugzilla-060d4fa6dd6e98ed45381ddf1e9b9ca2407ab3b3.tar.xz
Revert "Bug 1409957 - Create polling daemon to query Phabricator for recent transcations and update bug data according to revision changes"
Diffstat (limited to 'extensions/PhabBugz/bin')
-rwxr-xr-xextensions/PhabBugz/bin/phabbugz_feed.pl50
-rwxr-xr-xextensions/PhabBugz/bin/update_project_members.pl41
2 files changed, 18 insertions, 73 deletions
diff --git a/extensions/PhabBugz/bin/phabbugz_feed.pl b/extensions/PhabBugz/bin/phabbugz_feed.pl
deleted file mode 100755
index 9db491bd0..000000000
--- a/extensions/PhabBugz/bin/phabbugz_feed.pl
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/perl
-
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This Source Code Form is "Incompatible With Secondary Licenses", as
-# defined by the Mozilla Public License, v. 2.0.
-
-use 5.10.1;
-use strict;
-use warnings;
-
-use lib qw(. lib local/lib/perl5);
-
-BEGIN {
- use Bugzilla;
- Bugzilla->extensions;
-}
-
-use Bugzilla::Extension::PhabBugz::Daemon;
-Bugzilla::Extension::PhabBugz::Daemon->start();
-
-=head1 NAME
-
-phabbugz_feed.pl - Query Phabricator for interesting changes and update bugs related to revisions.
-
-=head1 SYNOPSIS
-
- phabbugz_feed.pl [OPTIONS] COMMAND
-
- OPTIONS:
- -f Run in the foreground (don't detach)
- -d Output a lot of debugging information
- -p file Specify the file where phabbugz_feed.pl should store its current
- process id. Defaults to F<data/phabbugz_feed.pl.pid>.
- -n name What should this process call itself in the system log?
- Defaults to the full path you used to invoke the script.
-
- COMMANDS:
- start Starts a new phabbugz_feed daemon if there isn't one running already
- stop Stops a running phabbugz_feed daemon
- restart Stops a running phabbugz_feed if one is running, and then
- starts a new one.
- check Report the current status of the daemon.
- install On some *nix systems, this automatically installs and
- configures phabbugz_feed.pl as a system service so that it will
- start every time the machine boots.
- uninstall Removes the system service for phabbugz_feed.pl.
- help Display this usage info
diff --git a/extensions/PhabBugz/bin/update_project_members.pl b/extensions/PhabBugz/bin/update_project_members.pl
index 06cc55626..bdc054e1a 100755
--- a/extensions/PhabBugz/bin/update_project_members.pl
+++ b/extensions/PhabBugz/bin/update_project_members.pl
@@ -20,9 +20,11 @@ use Bugzilla::Constants;
use Bugzilla::Error;
use Bugzilla::Group;
-use Bugzilla::Extension::PhabBugz::Project;
use Bugzilla::Extension::PhabBugz::Util qw(
- get_phab_bmo_ids
+ create_project
+ get_members_by_bmo_id
+ get_project_phid
+ set_project_members
);
Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
@@ -53,22 +55,23 @@ unless ($phab_sync_groups = Bugzilla->params->{phabricator_sync_groups}) {
my $sync_groups = Bugzilla::Group->match({ name => [ split('[,\s]+', $phab_sync_groups) ] });
foreach my $group (@$sync_groups) {
+ my @users = get_group_members($group);
+
# Create group project if one does not yet exist
my $phab_project_name = 'bmo-' . $group->name;
- my $project = Bugzilla::Extension::PhabBugz::Project->new({
- name => $phab_project_name
- });
- if (!$project->id) {
- $project = Bugzilla::Extension::PhabBugz::Project->create({
- name => $phab_project_name,
- description => 'BMO Security Group for ' . $group->name
- });
+ my $project_phid = get_project_phid($phab_project_name);
+ if (!$project_phid) {
+ $project_phid = create_project($phab_project_name, 'BMO Security Group for ' . $group->name);
}
- my @group_members = get_group_members($group);
+ # Get the internal user ids for the bugzilla group members
+ my $phab_user_ids = [];
+ if (@users) {
+ $phab_user_ids = get_members_by_bmo_id(\@users);
+ }
- $project->set_members(\@group_members);
- $project->update();
+ # Set the project members to the exact list
+ set_project_members($project_phid, $phab_user_ids);
}
sub get_group_members {
@@ -81,13 +84,5 @@ sub get_group_members {
$users{$user->id} = $user;
}
}
-
- # Look up the phab ids for these users
- my $phab_users = get_phab_bmo_ids({ ids => [ keys %users ] });
- foreach my $phab_user (@{ $phab_users }) {
- $users{$phab_user->{id}}->{phab_phid} = $phab_user->{phid};
- }
-
- # We only need users who have accounts in phabricator
- return grep { $_->phab_phid } values %users;
-} \ No newline at end of file
+ return values %users;
+}