File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ ### 1.3.0
2+ - Add issue lock/unlock functionality.
3+
14### 1.2.2
25- Warn instead of error when issue number file write fails.
36- Optimize issue operation customization.
Original file line number Diff line number Diff line change 55
66use octocrab;
77use octocrab:: models:: IssueState ;
8+ use octocrab:: params:: LockReason ;
89use octocrab:: params:: State ;
910
1011// allowed operations for github issue interactions
@@ -295,6 +296,28 @@ impl<'issue> Issue<'issue> {
295296 match self . number {
296297 // issue number specified
297298 Some ( number) => {
299+ // first lock or unlock the issue if specified
300+ if let Some ( lock) = self . lock {
301+ if lock {
302+ match issues. lock ( number, LockReason :: Resolved ) . await {
303+ Ok ( _) => log:: debug!( "issue number {number} locked" ) ,
304+ Err ( error) => {
305+ log:: error!( "the issue number {number} could not be locked" ) ;
306+ log:: error!( "{error}" ) ;
307+ return Err ( "issue not locked" ) ;
308+ }
309+ }
310+ } else {
311+ match issues. unlock ( number) . await {
312+ Ok ( _) => log:: debug!( "issue number {number} unlocked" ) ,
313+ Err ( error) => {
314+ log:: error!( "the issue number {number} could not be unlocked" ) ;
315+ log:: error!( "{error}" ) ;
316+ return Err ( "issue not unlocked" ) ;
317+ }
318+ }
319+ }
320+ }
298321 // build the issue
299322 let mut issue = issues. update ( number) ;
300323 // ... with optional parameters
You can’t perform that action at this time.
0 commit comments