kraemer-lab / GRAPEVNE

Graphical Analytical Pipeline Development Evironment
MIT License
7 stars 3 forks source link

Prompt when local modules are out-of-sync with remote #340

Closed jsbrittain closed 2 months ago

jsbrittain commented 3 months ago

When a local repository is a clone of a remote github repository, we should be able to facility updates in both directions, namely:

We can granularise the process by checking which modules are out-of-sync with remote by running

git diff --name-only origin/main -- .

or replacing . with /path/to/folder if we only want to check specific projects. This will list files with changes.

We can check if a repo is out-of-date with the remote by using GitPython as follows:

import git
repo = git.Repo('.')  # current folder
repo.remotes.origin.fetch()  # can just fetch branch here, e.g. fetch('main')
commits_match = repo.heads['main'].commit == repo.remotes.origin.refs['main'].commit

Node solutions like isomorphic-git offer platform independent implementations of git, but unfortunately do not perform well in practise due to e.g. lack of ssh repo support.