Storing Application in GitLab

Skip to first unread message


Apr 28, 2022, 10:04:00 AM4/28/22
to Users Mailing List

So I posted a message a while back about managing version controlling/source code changes between two instances of  Below is the Python script I've written which has been working for me.

The entire process is completely upside down, I develop the application in a Development instance of my application, run the Python script to create 'source code' (this is incremental) and then commit this to my GitLab repo which handles only committing what's changed.  

I can then use the GitLab UI to show me the diffs between production and development.  It means I have point in time backups of the application so if I wreck something then I can go back to it.  Mostly this is to give me visibility of which bits of the application I "touched" when I made changes because often this is multiple items, plus database changes representing permissions, form layouts, indexes etc.

The Python script is relatively straight-forward, you pass the location of the installed application, the folder where you want to create your source repository, and a message for Git to commit the changes like this:

/bin/python3 /home/applications/codestash/ -j ../training-dev -o ../training-dev-src -m "Initial work on competency management"

It does the following:
  1. creates a copy of the CSS and index.html files
  2. creates a copy of the admin.sqlite database with a date/time stamp (these aren't committed to the repo)
  3. Runs sqldiff for each of the tables in the current admin.sqlite compared to the one from the time before (defined at the top of the script) and outputs individual SQL files for each table showing what's changed so these can be shown in GitLab
  4. Gets the categories (catalogs, journals, details etc.) from the sqlite
  5. Pulls the JSON, JS and Python code for each item out of the database into files named after the item and in folders based on the category
  6. Commits it to GitLab
Some screenshots which hopefully explain a bit better...

**diffs** is the SQL diffs from the tables in admin.sqlite which have changed - here I added some indices to some tables so the sqldiff process shows what changed



Screenshot 2022-04-28 at 14.38.28.png

**Source code**

Here is the output from generating a "src" tree

Screenshot 2022-04-28 at 14.45.03.png

In GitLab:

Screenshot 2022-04-28 at 14.57.13.png

If anyone wants to ask any questions etc. then feel free.  The script is attached but provided as-is, no warranty express or implied, under the MIT License.

Danijel Kaurin

Apr 28, 2022, 1:42:09 PM4/28/22
to Users Mailing List
Thanks Ali.

Great work for both posts.

Andrew Yushev

Apr 29, 2022, 4:18:47 AM4/29/22
to Danijel Kaurin, Users Mailing List
I totally agree with Danijel.

чт, 28 апр. 2022 г. в 20:42, Danijel Kaurin <>:
You received this message because you are subscribed to the Google Groups " Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Drazen D. Babic

May 1, 2022, 10:35:35 AM5/1/22
to Users Mailing List
HI Ali, 

cheers for the script! Tried it but no go. Is the dependency gitpython or python-git?
So in demo folder I do this:
~/Downloads/ $ python ../../ -j ../demo/ -o ../../codestash_demo_git -m "Initial"
Traceback (most recent call last):
  File "../../", line 80, in copy_database
    fp = shutil.copy2(db, output_path)
  File "/usr/local/lib/python3.8/", line 432, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/local/lib/python3.8/", line 261, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/dbabic/Downloads/codestash_demo_git/databases/admin-1651415189.sqlite'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "../../", line 190, in <module>
    db_copy = copy_database(db, output_path)
  File "../../", line 83, in copy_database
    print(f'The database copy process failed with {e.message}')
AttributeError: 'FileNotFoundError' object has no attribute 'message'


Only index.html and css/project.css folder was created.



May 6, 2022, 6:52:52 AM5/6/22
to Users Mailing List

Apologies, I've been a bit snowed under.  There were some issues around creating default directories etc. when running for the first time so I've added some error checking code and creation of missing directories stuff too.  Also, the script will check to make sure the output folder is already initialised as a Git repo if you're using the automatic commit option (which is now optional so you can generate the source code tree without committing)

Please find the latest version attached.


Drazen D. Babic

May 6, 2022, 8:11:44 AM5/6/22
to Users Mailing List
This is fantastic! I see the potential even with no git, like naming all with timestamp and doing a diff! 



Maxwell Morais

May 6, 2022, 8:30:40 AM5/6/22
to Drazen D. Babic, Users Mailing List
I loved that!

This will for sure help in resolving a problem of having more than 1 dev working around the same project!

May can help also to define apps as module, so we can develop small apps (as modules) and combine they in a single big app!

For sure I'll take a deep look on this project possibilities!


You received this message because you are subscribed to the Google Groups " Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
Reply all
Reply to author
0 new messages