This commit is contained in:
Martin Green 2022-06-19 01:16:53 +01:00
parent 18dbb847e3
commit d560b17ab6

View File

@ -341,13 +341,14 @@ def editexpopage(request, path):
return render(request,'errors/generic.html', {'message': message}) return render(request,'errors/generic.html', {'message': message})
try: try:
cp_add = subprocess.run([git, "add", filename.encode(sysdefaultencoding)], cwd=cwd, capture_output=True, text=True) encoded_filename = filename.encode(sysdefaultencoding)
cp_add = subprocess.run([git, "add", encoded_filename], cwd=cwd, capture_output=True, text=True)
if cp_add.returncode != 0: if cp_add.returncode != 0:
msgdata = 'Ask a nerd to fix this.\n\n' + cp_add.stderr + '\n\n' + cp_add.stdout + '\n\nreturn code: ' + str(cp_add.returncode) msgdata = 'Ask a nerd to fix this.\n\n' + cp_add.stderr + '\n\n' + cp_add.stdout + '\n\nreturn code: ' + str(cp_add.returncode)
message = f'CANNOT git on server for this file {filename}. Edits saved but not added to git.\n\n' + msgdata message = f'CANNOT git on server for this file {filename}. Edits saved but not added to git.\n\n' + msgdata
return render(request,'errors/generic.html', {'message': message}) return render(request,'errors/generic.html', {'message': message})
cp_commit = subprocess.run([git, "commit", "-m", f'Troggle online: Edit this page - {filename}'], cwd=cwd, capture_output=True, text=True) cp_commit = subprocess.run([git, "commit", "-m", f'Troggle online: Edit this page - {encoded_filename}'], cwd=cwd, capture_output=True, text=True)
# This produces return code = 1 if it commits OK, but when the repo still needs to be pushed to origin/expoweb # This produces return code = 1 if it commits OK, but when the repo still needs to be pushed to origin/expoweb
if cp_commit.returncode != 0 and cp_commit.stdout != 'nothing to commit, working tree clean': if cp_commit.returncode != 0 and cp_commit.stdout != 'nothing to commit, working tree clean':
msgdata = 'Ask a nerd to fix this.\n\n' + cp_commit.stderr + '\n\n' + cp_commit.stdout + '\n\nreturn code: ' + str(cp_commit.returncode) msgdata = 'Ask a nerd to fix this.\n\n' + cp_commit.stderr + '\n\n' + cp_commit.stdout + '\n\nreturn code: ' + str(cp_commit.returncode)