77github_user_name = os .getenv ("GITHUB_USERNAME" )
88user_email = os .getenv ("USER_EMAIL" )
99user_token = os .getenv ("GITHUB_TOKEN" )
10- branch_name = uuid .uuid4 ().hex + '-' + github_user_name
10+ if github_user_name :
11+ global branch_name
12+ branch_name = uuid .uuid4 ().hex + '-' + github_user_name
1113
1214# Configuration file for jupyter-notebook.
1315
@@ -599,9 +601,11 @@ def gitconfig(user_name, user_email, user_token, branch_name):
599601 out , err , retcode = _system ('git remote set-url origin ' + final_url )
600602 out , err , retcode = _system ('git checkout -b ' + branch_name )
601603
602- gitconfig (user_name , user_email , user_token , branch_name )
603604
604- c .FileContentsManager .post_save_hook = save
605+ # Only create a post-save hook if required env vars are set
606+ if user_name and github_user_name and user_email and user_token :
607+ gitconfig (user_name , user_email , user_token , branch_name )
608+ c .FileContentsManager .post_save_hook = save
605609
606610##
607611#c.FileContentsManager.root_dir = ''
@@ -648,4 +652,4 @@ def gitconfig(user_name, user_email, user_token, branch_name):
648652## Whitelist of allowed kernel names.
649653#
650654# By default, all installed kernels are allowed.
651- #c.KernelSpecManager.whitelist = set()
655+ #c.KernelSpecManager.whitelist = set()
0 commit comments