Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Chessa
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Síle Ekaterin Liszka
Chessa
Commits
7977e5ac
Commit
7977e5ac
authored
2 years ago
by
Síle Ekaterin Liszka
Browse files
Options
Downloads
Patches
Plain Diff
Chessa::Bug::Adelie: error-handling, bitch
parent
8322374f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Chessa/Bug/Adelie.pm
+28
-9
28 additions, 9 deletions
scripts/Chessa/Bug/Adelie.pm
with
28 additions
and
9 deletions
scripts/Chessa/Bug/Adelie.pm
+
28
−
9
View file @
7977e5ac
...
...
@@ -22,6 +22,7 @@ sub new($class, $http, $log, $msg, $conf) {
$self
->
{
msg
}
=
$msg
;
$self
->
{
conf
}
=
$conf
;
$self
->
{
irc
}
=
$self
->
{
conf
}{
irc
};
$self
->
{
http
}
=
$http
;
$self
->
{
projects
}
=
{};
load_projects
(
$self
,
$http
,
'
https://git.adelielinux.org/api/v4/projects
');
...
...
@@ -40,12 +41,11 @@ sub error($self, $msg, $on_info=undef, $errors=0) {
$self
->
log
(
$msg
,
$on_info
,
$errors
);
}
sub
load_projects
($self,
$http,
$uri) {
$http
->
do_request
(
sub
load_projects
($self, $uri) {
$
self
->
{
http
}
->
do_request
(
uri
=>
$uri
,
on_response
=>
sub
($response) {
$self
->
{
log
}("
Fetched projects from
$uri
");
projects
(
$self
,
$http
,
$response
);
projects
(
$self
,
$response
);
},
on_error
=>
sub
($error) {
$self
->
{
log
}("
Couldn't fetch projects:
$error
");
croak
$error
;
...
...
@@ -53,12 +53,11 @@ sub load_projects($self, $http, $uri) {
);
}
sub
projects
($self,
$http,
$response) {
sub
projects
($self, $response) {
my
$json
=
JSON::
MaybeXS
->
new
->
utf8
->
decode
(
$response
->
decoded_content
);
for
my
$item
(
@
{
$json
})
{
$self
->
{
projects
}{
$item
->
{
path_with_namespace
}}
=
$item
->
{
id
};
$self
->
{
log
}(
$item
->
{
path_with_namespace
}
.
'
=
'
.
$item
->
{
id
});
}
my
$link
=
$response
->
header
('
Link
');
my
@links
=
split
/, /
,
$link
;
...
...
@@ -66,7 +65,7 @@ sub projects($self, $http, $response) {
if
(
$i
=~
/"next"$/
)
{
$i
=~
/<(.*?)>/
;
$link
=
$
1
;
load_projects
(
$self
,
$http
,
$link
);
load_projects
(
$self
,
$link
);
last
;
}
}
...
...
@@ -79,7 +78,7 @@ sub wants($self, $project) {
return
0
;
}
sub
handle
($self,
$http,
$on_info, $data, $errors) {
sub
handle
($self, $on_info, $data, $errors) {
my
(
$project
,
$num
,
$type
)
=
@
{
$data
};
$self
->
log
("
Got
$project
$type
$num
");
...
...
@@ -110,7 +109,7 @@ sub handle($self, $http, $on_info, $data, $errors) {
$base
.=
"
$type
/
$num
";
$self
->
log
("
Requesting
$base
");
$http
->
do_request
(
$
self
->
{
http
}
->
do_request
(
uri
=>
$base
,
on_response
=>
sub
($response) {
$func
->
(
$self
,
$response
,
$on_info
,
$data
,
$errors
);
...
...
@@ -125,6 +124,11 @@ sub issue($self, $response, $on_info, $data, $errors) {
my
$json
=
JSON::
MaybeXS
->
new
->
utf8
->
decode
(
$response
->
decoded_content
);
if
(
!
$response
->
is_success
)
{
$self
->
{
log
}(
$self
->
{
msg
}('
Error
',
$json
->
{
message
}),
$on_info
,
$errors
);
return
;
}
my
%d
=
(
author
=>
$json
->
{
author
}{
name
}
.
'
(@
'
.
$json
->
{
author
}{
username
}
.
'
)
',
title
=>
$json
->
{
title
},
...
...
@@ -144,6 +148,11 @@ sub mr($self, $response, $on_info, $data, $errors) {
my
$json
=
JSON::
MaybeXS
->
new
->
utf8
->
decode
(
$response
->
decoded_content
);
if
(
!
$response
->
is_success
)
{
$self
->
{
log
}(
$self
->
{
msg
}('
Error
',
$json
->
{
message
}),
$on_info
,
$errors
);
return
;
}
my
%d
=
(
author
=>
$json
->
{
author
}{
name
}
.
'
(@
'
.
$json
->
{
author
}{
username
}
.
'
)
',
title
=>
$json
->
{
title
},
...
...
@@ -182,6 +191,11 @@ sub commit($self, $response, $on_info, $data, $errors) {
my
$json
=
JSON::
MaybeXS
->
new
->
utf8
->
decode
(
$response
->
decoded_content
);
if
(
!
$response
->
is_success
)
{
$self
->
{
log
}(
$self
->
{
msg
}('
Error
',
$json
->
{
message
}),
$on_info
,
$errors
);
return
;
}
my
%d
=
(
author
=>
$json
->
{
author_name
}
.
'
<
'
.
$json
->
{
author_email
}
.
'
>
',
commit
=>
$json
->
{
committer_name
}
.
'
<
'
.
$json
->
{
committer_email
}
.
'
>
',
...
...
@@ -203,6 +217,11 @@ sub snippet($self, $response, $on_info, $data, $errors) {
my
$json
=
JSON::
MaybeXS
->
new
->
utf8
->
decode
(
$response
->
decoded_content
);
if
(
!
$response
->
is_success
)
{
$self
->
{
log
}(
$self
->
{
msg
}('
Error
',
$json
->
{
message
}),
$on_info
,
$errors
);
return
;
}
my
%d
=
(
author
=>
$json
->
{
author
}{
name
}
.
'
(@
'
.
$json
->
{
author
}{
username
}
.
'
)
',
title
=>
$json
->
{
title
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment