Introduction
If your work with the Framework development has been done using a copy detached from the local clone of your online (e.g. GitHub) repo of the Framework, this post describes how to copy your changes to a local clone and then add, commit and push these changes to your online repo. The solution is a python package that copies all updates to your local clone and that also writes the Terminal commands for add, commit and push.
Framework submodule structure
Karttur’s GeoImagine Framework available at GitHub is built from a “superproject” (or container) repository with around 40 individual repositories attached as submodules. Each submodule (or repo) contains a customised Python package belonging to the Framework. In the online GitHub repo, each submodule has a 2-part name:
geoimaginexx_package
where xx is the Framework version (02 when writing this in October 2021), and package is the python package name that is used in the Framework. The conversion in the naming:
geoimaginexx_package -> package
is defined in the superproject as described in the post on git superproject and submodels.
submodule_stage-commit-push_script.py
The python module (script) submodule_stage-commit-push_script is part of the Framework, and found under the support package. The parameters required for running the script are given directly in the __main__ section:
copyProject = True
copyProjectDoc = False
branch = 'main'
commitMsg = 'updates oct 2021'
ignoreL = ['__pycache__','.DS_Store']
home = os.path.expanduser('~')
scriptFPN = os.path.join(home, 'submodule_stage_commit_push.sh')
srcProjectFP = '/Users/thomasgumbricht/eclipse-workspace/2020-03_geoimagine/karttur_v202003/geoimagine'
gitHubFP = '/Users/thomasgumbricht/GitHub/'
gitHubAccount = 'karttur'
prefix = 'geoimagine02'
submoduleL = ['ancillary','assets','basins','copernicus',
'dem','export','exract',
'gis','grace','grass','ktgdal',
'ktgrass','ktnumba',
'ktpandas','landsat','layout',
'modis','npproc',
'params','postgresdb','projects',
'region','sentinel',
'setup_db','setup_processes','smap','support',
'timeseries','updatedb','userproj',
'zipper']
if copyProject:
CopyProject()
WriteScript()
Set all the variables and then just run the script. All updated documents will be changed in the destination directory (gitHubFP), and a shell script file created under the home directory (home). To add, commit and push the changes to the online (origin) repo, run the shell script after the python module is executed. The first lines of the shell script created from the above parameters look like this:
cd /Users/thomasgumbricht/GitHub/geoimagine02-ancillary
echo "${PWD}"
git add .
git commit -m "updates oct 2021"
git push origin main