@@ -22,7 +22,10 @@ const syncJob = CronJob.from({
2222 onTick : ( cb ) => {
2323 logger . info ( 'Running sync job' )
2424 syncAll ( )
25- . catch ( ( e ) => logger . error ( e ) )
25+ . catch ( ( e ) => {
26+ logger . error ( 'Uncaught error in sync job' )
27+ logger . error ( e )
28+ } )
2629 . finally ( ( ) => cb ( ) )
2730 } ,
2831 onComplete : ( ) => {
@@ -34,7 +37,7 @@ syncJob.start()
3437
3538async function syncAll ( ) {
3639 logger . info ( 'Fetching all repositories' )
37- const repos = await api . Groups . allProjects ( pn ! . id )
40+ const repos = await api . Groups . allProjects ( pn ! . id , { visibility : 'public' } )
3841
3942 // for testing purposes
4043 if ( process . env . TRUNCATE_REPOS ) {
@@ -49,23 +52,32 @@ async function syncAll() {
4952 const git = simpleGit ( dir )
5053 logger . info ( `Fetching updates for ${ repo . path } ` )
5154 if ( await git . checkIsRepo ( CheckRepoActions . IS_REPO_ROOT ) ) {
52- await git . fetch ( )
53- const res = await git . pull ( )
54- if ( res . files . length ) {
55- logger . info (
56- `Successfully pulled ${ repo . path } : +${ res . summary . changes } -${ res . summary . deletions } ~${ res . summary . insertions } `
57- )
55+ try {
56+ await git . fetch ( )
57+ const res = await git . pull ( )
58+ if ( res . files . length )
59+ logger . info (
60+ `Successfully pulled ${ repo . path } : +${ res . summary . changes } -${ res . summary . deletions } ~${ res . summary . insertions } `
61+ )
62+ } catch ( e ) {
63+ logger . error ( `Failed to pull ${ repo . path } ` )
64+ logger . error ( e )
5865 }
5966 } else {
6067 logger . error ( `Not a git repository: ${ repo . path } . How did this happen?` )
6168 }
6269 } else {
6370 logger . info ( `Cloning ${ repo . path } ` )
64- const res = await simpleGit ( 'repos' ) . clone ( repo . http_url_to_repo , {
65- '--filter' : 'tree:0' ,
66- '--single-branch' : null ,
67- } )
68- logger . info ( `Successfully cloned ${ repo . path } : +${ res } ` )
71+ try {
72+ const res = await simpleGit ( 'repos' ) . clone ( repo . http_url_to_repo , {
73+ '--filter' : 'tree:0' ,
74+ '--single-branch' : null ,
75+ } )
76+ logger . info ( `Successfully cloned ${ repo . path } : +${ res } ` )
77+ } catch ( e ) {
78+ logger . error ( `Failed to clone ${ repo . path } ` )
79+ logger . error ( e )
80+ }
6981 }
7082 }
7183}
0 commit comments