File tree Expand file tree Collapse file tree 2 files changed +26
-23
lines changed Expand file tree Collapse file tree 2 files changed +26
-23
lines changed Original file line number Diff line number Diff line change @@ -23,4 +23,27 @@ impl GhLabel {
23
23
24
24
Ok ( labels)
25
25
}
26
+
27
+ pub fn create ( & self , repository : & str ) -> anyhow:: Result < ( ) > {
28
+ let output = Command :: new ( "gh" )
29
+ . arg ( "-R" )
30
+ . arg ( repository)
31
+ . arg ( "label" )
32
+ . arg ( "create" )
33
+ . arg ( & self . name )
34
+ . arg ( "--color" )
35
+ . arg ( & self . color )
36
+ . arg ( "--force" )
37
+ . output ( ) ?;
38
+
39
+ if !output. status . success ( ) {
40
+ Err ( anyhow:: anyhow!(
41
+ "failed to create label `{}`: {}" ,
42
+ self . name,
43
+ String :: from_utf8_lossy( & output. stderr)
44
+ ) )
45
+ } else {
46
+ Ok ( ( ) )
47
+ }
48
+ }
26
49
}
Original file line number Diff line number Diff line change @@ -449,29 +449,9 @@ impl Display for GithubAction<'_> {
449
449
impl GithubAction < ' _ > {
450
450
pub fn execute ( self , repository : & str , timeframe : & str ) -> anyhow:: Result < ( ) > {
451
451
match self {
452
- GithubAction :: CreateLabel {
453
- label : GhLabel { name, color } ,
454
- } => {
455
- let output = Command :: new ( "gh" )
456
- . arg ( "-R" )
457
- . arg ( repository)
458
- . arg ( "label" )
459
- . arg ( "create" )
460
- . arg ( & name)
461
- . arg ( "--color" )
462
- . arg ( & color)
463
- . arg ( "--force" )
464
- . output ( ) ?;
465
-
466
- if !output. status . success ( ) {
467
- Err ( anyhow:: anyhow!(
468
- "failed to create label `{}`: {}" ,
469
- name,
470
- String :: from_utf8_lossy( & output. stderr)
471
- ) )
472
- } else {
473
- Ok ( ( ) )
474
- }
452
+ GithubAction :: CreateLabel { label } => {
453
+ label. create ( repository) ?;
454
+ Ok ( ( ) )
475
455
}
476
456
477
457
GithubAction :: CreateIssue {
You can’t perform that action at this time.
0 commit comments