1616site_dir = os .path .join (root_dir , 'site' )
1717
1818
19- def check_git_clean (dirname ):
20- if subprocess .check_output (['git' , 'status' , '-uno' , '--porcelain' ], text = True , cwd = dirname ).strip ():
21- print (f'{ dirname } : tree is not clean' )
22- sys .exit (1 )
19+ def is_git_clean (dirname ):
20+ return subprocess .check_output (['git' , 'status' , '-uno' , '--porcelain' ], text = True , cwd = dirname ).strip () == ''
2321
2422
2523def main (args ):
@@ -30,8 +28,12 @@ def main(args):
3028
3129 assert os .path .isdir (site_out )
3230 print (f'Updating docs in: { site_out } ' )
33- check_git_clean (site_out )
34- check_git_clean (root_dir )
31+ if not is_git_clean (site_out ):
32+ print (f'{ site_out } : tree is not clean' )
33+ return 1
34+ if not is_git_clean (root_dir ):
35+ print (f'{ root_dir } : tree is not clean' )
36+ return 1
3537
3638 # Ensure the -site checkout is up-to-date
3739 subprocess .check_call (['git' , 'fetch' , 'origin' ], cwd = site_out )
@@ -40,6 +42,10 @@ def main(args):
4042 # Build and install the docs
4143 subprocess .check_call (['make' , 'install' , f'EMSCRIPTEN_SITE={ site_out } ' ], cwd = site_dir )
4244
45+ if is_git_clean (site_out ):
46+ print ('docs are up-to-date; no changes found' )
47+ return 0
48+
4349 # Create a new branch and commit the changes.
4450 subprocess .check_call (['git' , 'checkout' , '-b' , 'update' ], cwd = site_out )
4551 subprocess .check_call (['git' , 'add' , '.' ], cwd = site_out )
@@ -48,6 +54,7 @@ def main(args):
4854 message = 'Update emscripten website\n \n '
4955 message += f'These docs were generated based on git revision { hash } '
5056 subprocess .run (['git' , 'commit' , '-F' , '-' ], input = message , text = True , cwd = site_out )
57+ return 2
5158
5259
5360if __name__ == '__main__' :
0 commit comments