From 3fbf7cfcd1ec22f72ec97aab3614688ac489a0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Wed, 1 Oct 2025 13:51:51 -0300 Subject: [PATCH] Use GET for the login endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomás Cohen Arazi --- lib/GitBz/Commands.pm | 16 ++++++++++++++-- lib/GitBz/Config.pm | 10 +--------- lib/GitBz/RestClient.pm | 13 +++++-------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/lib/GitBz/Commands.pm b/lib/GitBz/Commands.pm index ae8d56c..154978f 100644 --- a/lib/GitBz/Commands.pm +++ b/lib/GitBz/Commands.pm @@ -41,8 +41,20 @@ sub new { ); # Auto-login if credentials available - if ( $ENV{BUGZILLA_USER} && $ENV{BUGZILLA_PASSWORD} ) { - $client->login( $ENV{BUGZILLA_USER}, $ENV{BUGZILLA_PASSWORD} ); + my $username = $ENV{BUGZILLA_USER}; + my $password = $ENV{BUGZILLA_PASSWORD}; + + # Try git config if env vars not set + if ( !$username || !$password ) { + my $tracker_section = qq{bz-tracker "$tracker"}; + my $tracker_config = $config->{config}->{$tracker_section}; + + $username ||= $tracker_config->{'bz-user'} if $tracker_config; + $password ||= $tracker_config->{'bz-password'} if $tracker_config; + } + + if ( $username && $password ) { + $client->login( $username, $password ); } return bless { diff --git a/lib/GitBz/Config.pm b/lib/GitBz/Config.pm index af8ffd3..d3f9edc 100644 --- a/lib/GitBz/Config.pm +++ b/lib/GitBz/Config.pm @@ -27,14 +27,6 @@ my $DEFAULT_CONFIG = { 'default-product' => 'Koha', path => '/bugzilla3', }, - 'bugzilla.gnome.org' => { - https => 1, - 'default-priority' => 'Normal', - }, - 'bugs.freedesktop.org' => { - https => 1, - 'default-priority' => 'medium', - }, }; my $GIT_CONFIG = { @@ -46,7 +38,7 @@ my $GIT_CONFIG = { sub load { my ($class) = @_; - my $config_file = File::HomeDir->my_home . '/.gitbzrc'; + my $config_file = File::HomeDir->my_home . '/.gitconfig'; my $config = -f $config_file ? Config::Tiny->read($config_file) : {}; # Load git config diff --git a/lib/GitBz/RestClient.pm b/lib/GitBz/RestClient.pm index 612f8f0..83217e5 100644 --- a/lib/GitBz/RestClient.pm +++ b/lib/GitBz/RestClient.pm @@ -46,14 +46,11 @@ sub new { sub login { my ( $self, $username, $password ) = @_; - my $response = $self->{ua}->post( - $self->{base_url} . '/login', - Content_Type => 'application/json', - Content => encode_json( - { - login => $username, - password => $password - } + my $response = $self->{ua}->get( + sprintf( + "%s/login?login=%s&password=%s", + $self->{base_url}, $username, + $password ) ); -- 2.51.0