I am making a game and suddenly my game stopped working.
I am not sure what happened and spent a whole day to debug, and finally found the root cause is because of one script change.
normally with git I could just diff the current version and the earlier version. and found the problem almost immediately.
I think it is a really huge problem for playcanvas since it’s lack of version control, the project can not go big. even with “not recommended” legacy script system which has version control, I still need to start a brand new project to add it, not with an already made project.
even with the editor’s change could show in the diff.
I know support version control on a web editor is hard, but is there a plan for this? I really like the easy to use editor but lack of version control makes me feel unsafe.
Possible workaround - download your build and commit it to git.
Little annoying, but working.
And I totally agree with you - version control is extremely important for big project.
It would be great to see who made changes in project.
2 Likes
I’m on the ORG plan so have access to the API. I use a script to export the project as is (not a build) that I check into git every time I’ve completed a feature.
1 Like
that sound nice, I am considering upgrade to ORG for this one. currently using person plan.
is that possible you share the script? forgive me if I asked an inappropriate question…
Script:
import sys
import requests
import time
import subprocess
import os
import shutil
import zipfile
import io
import re
FNULL = open(os.devnull, 'w')
snapshot_path = '../snapshots-project'
project_id = 'XXXXXX'
export_url = 'https://playcanvas.com/api/projects/{}/export'.format(project_id)
job_url_template = 'https://playcanvas.com/api/jobs/{}'
headers = {
'Authorization':'Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
'Content-Type':'application/json'
}
job_poll_interval_secs = 1
job_id = -1
archive_url = ''
# Request the archive of the project
print('Requesting project archive job')
r = requests.post(export_url, headers=headers)
if r.status_code == 200:
json = r.json()
status = json['status']
if status == 'running':
job_id = json['id']
elif status == 'complete':
archive_url = json['url']
else:
sys.exit(1)
else:
print('Error: {}'.format(r.status_code))
sys.exit(1)
if len(archive_url) == 0:
print('Waiting for job to complete')
# Poll job till its complete
job_url = job_url_template.format(str(job_id))
job_finished = False
while not job_finished:
r = requests.get(job_url, headers=headers)
if r.status_code == 200:
json = r.json()
status = json['status']
if status == 'complete':
archive_url = json['data']['url']
job_finished = True
elif status == 'running':
print('Still waiting')
time.sleep(job_poll_interval_secs)
else:
sys.exit(1)
else:
sys.exit(1)
# Remove all files from the snapshot directory
print('Clearing snapshot directory')
shutil.rmtree(snapshot_path)
os.mkdir(snapshot_path)
# Download zip from JSON response
print('Download archive from {}'.format(archive_url))
r = requests.get(archive_url)
z = zipfile.ZipFile(io.BytesIO(r.content))
# Unzip the archive
print('Unzipping archive')
z.extractall(snapshot_path)
3 Likes
yaustar:
import sys
import requests
import time
import subprocess
import os
import shutil
import zipfile
import io
import re
FNULL = open(os.devnull, ‘w’)
snapshot_path = ‘…/snapshots-project’
project_id = ‘XXXXXX’
export_url = ‘https://playcanvas.com/api/projects/{}/export ’.format(project_id)
job_url_template = ‘https://playcanvas.com/api/jobs/{} ’
headers = {
‘Authorization’:‘Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’,
‘Content-Type’:‘application/json’
}
job_poll_interval_secs = 1
job_id = -1
archive_url = ‘’
Request the archive of the project
print(‘Requesting project archive job’)
r = requests.post(export_url, headers=headers)
if r.status_code == 200:
json = r.json()
status = json[‘status’]
if status == 'running':
job_id = json['id']
elif status == 'complete':
archive_url = json['url']
else:
sys.exit(1)
else:
print(‘Error: {}’.format(r.status_code))
sys.exit(1)
if len(archive_url) == 0:
print(‘Waiting for job to complete’)
# Poll job till its complete
job_url = job_url_template.format(str(job_id))
job_finished = False
while not job_finished:
r = requests.get(job_url, headers=headers)
if r.status_code == 200:
json = r.json()
status = json['status']
if status == 'complete':
archive_url = json['data']['url']
job_finished = True
elif status == 'running':
print('Still waiting')
time.sleep(job_poll_interval_secs)
else:
sys.exit(1)
else:
sys.exit(1)
Remove all files from the snapshot directory
print(‘Clearing snapshot directory’)
shutil.rmtree(snapshot_path)
os.mkdir(snapshot_path)
Download zip from JSON response
print(‘Download archive from {}’.format(archive_url))
r = requests.get(archive_url)
z = zipfile.ZipFile(io.BytesIO(r.content))
Unzip the archive
print(‘Unzipping archive’)
z.extractall(snapshot_path)
thanks a lot! really appreciate it!
I finally got the script working and really appreciate your help
dave
January 14, 2019, 11:24pm
8
Just reviving this old conversation to say that we launched our integrated version control feature today.
We’re extremely happy to announce that we’ve rolled out our integrated version control to all PlayCanvas users. With this new feature everyone now is able to create checkpoints and branches in their projects, merge between branches and view the changes you have made since your last checkpoint.
[view-changes]
Access the version control dialog via VC button in your viewport.
[vc-button]
We’ve been testing the feature extensively internally and we’re sure that it’s going to be a big productivi…
1 Like
wow, such update!
thanks a lot, we have been waiting for so long.