Tools

GIT Sync - mirror a GIT repo as an nextCloud folder

Here at The GMU, https://www.thegmu.com, we want to be able to share our GIT document folder with our Dropbox-like file sharing software, nextCloud, https://nextcloud.org. Our company is just two people, the two owners. We are both software developers and are comfortable using GIT for document control. Our intitial requirement is to be able to share our documents under GIT version control using the same features provided by nextCloud. For example:

  1. We want to share files by email address with our accountant and other users who are not registered with our nextCloud server.

  2. We also want to be able to have user created groups for sharing with groups.

  3. We also want to have the ability to create temporary URL links for one time use.

All the features listed are available with nextCloud but missing from Github or Bitbucket where repositories are either public or private and no finer grain sharing control is available.

The design is simple enough in concept where the git repos are mirrored as read-only on the nextCloud host. The GIT sync tool updates nextCloud every minute with any new files or changes to the GIT repository.

The implementation was much more involved. For example one cannot just copy files from a GIT folder to the corresponding nextCloud folder because the file needs to be registered with the nextCloud database. This registration requires uploading the file from the server to the nextCloud software in the exact same way any client does.

GIT Sync Requirements:

  1. Mirror a GIT repo as read-only to a configured nextCloud user account.

  2. All accidental uploads to the GIT folder are to be reverted to the GIT version of the file.

  3. A special transfer directory, ‘Transfer’, will allow uploads.

  4. Files transfered to the transfer directory from say a phone are to be moved to an appropropriate GIT folder in a timely fashion.

  5. Files transfered are purged weekly.

  6. Daily email report of all files processed for the day.

  7. Daily email of all errors processing files included in the daily email report.

  8. Configuration file management. Adding a repo per user can be accomplished by creating a new configuration file.

  9. Include and exclude directory options. The GIT repo directories can be filtered by using either an include or exclude list.

Note

Linux shell commands are frequently executed instead of using built-in Python compatible functions for the following reasons.

  1. nextCloud files: sudo is required for nextCloud files that are owned by one account. Since we are using the Apache web server that account is ‘www-data’.

  2. GIT files: sudo is required for GIT files that are owned by one account on our server, ‘root’.

  3. davfs: sudo is required for the account that mounts the davfs folder used to upload to nextCloud.