[SOLVED] Without version control, is there anyway to "revert" if things messed up?

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

thanks a lot! really appreciate it!

I finally got the script working and really appreciate your help :slight_smile:

Just reviving this old conversation to say that we launched our integrated version control feature today.

1 Like

wow, such update!
thanks a lot, we have been waiting for so long. :+1: