1
1
import json
2
+ import pathlib
2
3
import logging
4
+ import tempfile
3
5
from typing import Optional
4
6
5
7
import dffml
@@ -11,24 +13,28 @@ async def gh_issue_create(
11
13
body : str ,
12
14
logger : Optional [logging .Logger ] = None ,
13
15
) -> str :
14
- async for event , result in dffml .run_command_events (
15
- [
16
- "gh" ,
17
- "issue" ,
18
- "create" ,
19
- "-R" ,
20
- repo_url ,
21
- "--title" ,
22
- title ,
23
- "--body" ,
24
- body ,
25
- ],
26
- logger = logger ,
27
- events = [dffml .Subprocess .STDOUT ],
28
- ):
29
- if event is dffml .Subprocess .STDOUT :
30
- # The URL of the issue created
31
- return result .strip ().decode ()
16
+ # Create tempdir to avoid issue body to long
17
+ with tempfile .TemporaryDirectory () as tempdir :
18
+ body_path = pathlib .Path (tempdir , "issue_body.txt" )
19
+ body_path .write_text (body )
20
+ async for event , result in dffml .run_command_events (
21
+ [
22
+ "gh" ,
23
+ "issue" ,
24
+ "create" ,
25
+ "-R" ,
26
+ repo_url ,
27
+ "--title" ,
28
+ title ,
29
+ "--body-file" ,
30
+ str (body_path ),
31
+ ],
32
+ logger = logger ,
33
+ events = [dffml .Subprocess .STDOUT ],
34
+ ):
35
+ if event is dffml .Subprocess .STDOUT :
36
+ # The URL of the issue created
37
+ return result .strip ().decode ()
32
38
33
39
34
40
async def gh_issue_update (
@@ -38,23 +44,27 @@ async def gh_issue_update(
38
44
* ,
39
45
logger : Optional [logging .Logger ] = None ,
40
46
) -> str :
41
- async for event , result in dffml .run_command_events (
42
- [
43
- "gh" ,
44
- "issue" ,
45
- "edit" ,
46
- issue_url ,
47
- "--title" ,
48
- title ,
49
- "--body" ,
50
- body ,
51
- ],
52
- logger = logger ,
53
- events = [dffml .Subprocess .STDOUT ],
54
- ):
55
- if event is dffml .Subprocess .STDOUT :
56
- # The URL of the issue created
57
- return result .strip ().decode ()
47
+ # Create tempdir to avoid issue body to long
48
+ with tempfile .TemporaryDirectory () as tempdir :
49
+ body_path = pathlib .Path (tempdir , "issue_body.txt" )
50
+ body_path .write_text (body )
51
+ async for event , result in dffml .run_command_events (
52
+ [
53
+ "gh" ,
54
+ "issue" ,
55
+ "edit" ,
56
+ issue_url ,
57
+ "--title" ,
58
+ title ,
59
+ "--body-file" ,
60
+ str (body_path ),
61
+ ],
62
+ logger = logger ,
63
+ events = [dffml .Subprocess .STDOUT ],
64
+ ):
65
+ if event is dffml .Subprocess .STDOUT :
66
+ # The URL of the issue created
67
+ return result .strip ().decode ()
58
68
59
69
60
70
async def gh_issue_search_by_title (
0 commit comments