@@ -20,31 +20,59 @@ var __importStar = (this && this.__importStar) || function (mod) {
20
20
} ;
21
21
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
22
22
const rest_1 = require ( "@octokit/rest" ) ;
23
- const node_fetch_1 = __importStar ( require ( "node-fetch" ) ) ;
24
- run ( ) ;
25
- async function run ( ) {
26
- const o = new rest_1 . Octokit ( { auth : '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' } ) ;
<
6D47
td data-grid-cell-id="diff-fb522e02f03d926bdba903915e1671c4a35b2a46a7fd1d6e3b0936a316cf29c7-27-22-0" data-selected="false" role="gridcell" style="background-color:var(--diffBlob-deletionNum-bgColor, var(--diffBlob-deletion-bgColor-num));text-align:center" tabindex="-1" valign="top" class="focusable-grid-cell diff-line-number position-relative left-side">27
- // const { data } = await o.request("/user");
28
- // console.log(data)
29
- const sha = 'fd3d6b191cf773f68ca6dfc57bc52e28513fd8d1' ;
30
- // const q = `repo:shiftcode/sc-commons next`
31
- // const q = `hash:${sha} repo:shiftcode/sc-commons rev:@*refs/heads/* type:diff`
32
- // const q = `repo:shiftcode/sc-commons@${sha} type:diff`
33
- // const q = `hash:${sha} rev:@*refs/heads/*`
34
- const q = `hash:${ sha } repo:shiftcode/sc-commons rev:@refs/heads/#102-fix-peer-deps-version type:diff` ;
35
- console . info ( `q: ${ q } ` ) ;
23
+ const https = __importStar ( require ( "https" ) ) ;
24
+ const token = process . env . GH_TOKEN ;
25
+ console . log ( token ) ;
26
+ const sha = 'fd3d6b191cf773f68ca6dfc57bc52e28513fd8d1' ;
27
+ runWithOctokit ( )
28
+ . then ( ( ) => runOther ( ) ) ;
29
+ async function runWithOctokit ( ) {
30
+ console . log ( `### execution with octokit client` ) ;
31
+ const o = new rest_1 . Octokit ( { auth : token } ) ;
32
+ const { data } = await o . request ( '/user' ) ;
33
+ console . log ( `current user: ${ data . login } ` ) ;
34
+ // query try out
35
+ /*
36
+ const q = `repo:shiftcode/sc-commons next`
37
+ const q = `hash:${sha} repo:shiftcode/sc-commons rev:@*refs/heads/* type:diff`
38
+ const q = `repo:shiftcode/sc-commons@${sha} type:diff`
39
+ const q = `hash:${sha} rev:@*refs/heads/*`
40
+ */
41
+ const q = `hash:${ sha } repo:shiftcode/sc-commons rev:@refs/heads/#102-fix-peer-deps-version` ;
42
+ console . info ( `execute with search query: ${ q } ` ) ;
36
43
const response = await o . rest . search . commits ( { q } ) ;
37
- console . log ( response ) ;
44
+ // seems like octokit will only return commits from default branch
45
+ console . log ( `found ${ response . data . total_count } commits for sha ${ sha } ` ) ;
38
46
for ( const { commit } of response . data . items ) {
39
47
console . log ( `----------------- ${ commit . url } -----------------` ) ;
40
48
console . log ( commit . message ) ;
41
49
console . log ( '-------------------------------------------------' ) ;
42
50
}
43
- const headers = new node_fetch_1 . Headers ( ) ;
44
- headers . set ( 'Authorization' , 'token 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' ) ;
45
- const response2 = await ( 0 , node_fetch_1 . default ) ( `https://api.github.com/repos/shiftcode/sc-commons/git/commits/${ sha } ` , {
46
- headers
51
+ }
52
+ async function runOther ( ) {
53
+ console . log ( `### execution with plain http request` ) ;
54
+ const url = `https://api.github.com/repos/shiftcode/sc-commons/git/commits/${ sha } ` ;
55
+ console . log ( url ) ;
56
+ const commit = ( await fetch ( url ) ) ; /* and others */
57
+ console . log ( `----------------- ${ commit . url } -----------------` ) ;
58
+ console . log ( commit . message ) ;
59
+ console . log ( '-------------------------------------------------' ) ;
60
+ }
61
+ async function fetch ( url ) {
62
+ return new Promise ( ( resolve ) => {
63
+ https . get ( url , {
64
+ headers : {
65
+ Authorization : `token ${ token } ` ,
66
+ 'User-Agent' : 'Github Skip Action' ,
67
+ } ,
68
+ } , res => {
69
+ let data = '' ;
70
+ res . on ( 'data' , chunk => {
71
+ data += chunk ;
72
+ } ) ;
73
+ res . on ( 'end' , ( ) => {
74
+ resolve ( JSON . parse ( data ) ) ;
75
+ } ) ;
76
+ } ) ;
47
77
} ) ;
48
- console . log ( response2 . status ) ;
49
- console . log ( await response2 . json ( ) ) ;
50
78
}
0 commit comments