using hooks with git source control from Matlab. Hooks that work from outside Matlab are not executed from within.

9 views (last 30 days)
Hello Everyone,
I'm working with Matlab 2016a try to get the source control going. Commit, Push, Fetch etc work fine, from both the context menu in the Current Folder Window and from the GUI shipped with git. But when I implement a server-sided hook in the remote repository, Matlab fails me by ignoring the hook. When I commit from outside Matlab, the hook works.
hook-file is located in ..\remote_repo\hooks by the name 'pre-receive' without extension. Source Code:
#!/usr/bin/env python
import matplotlib.pyplot as plt
import sys
plt.figure()
plt.show()
sys.exit(1)
The hook is written for testing purposes only. It opens a matplotlib window and when the window is closed, an error is thrown as the Push-Operation is aborted.
As I mentioned, when I push my commit from outside Matlab via the GUI, the expected happens, matplotlib-window and error. But when I push from the same local repository to the same remote repository, the push is successful...
Is there a way to execute hooks both server-sided and local ones from Matlab?
Thanks in advance and greetings,
Tobias
  2 Comments
Saurabh Gupta
Saurabh Gupta on 30 Jan 2017
MATLAB uses JGit for integration with Git. If the hooks that you intend to use are not supported by JGit, they will not work with MATLAB either.
Which operating system are you using? You may be required to configure cygwin, if you are on Windows, for using Git hooks.
Tobias Huth
Tobias Huth on 2 Feb 2017
Edited: Tobias Huth on 2 Feb 2017
Dear Saurabh,
The machine I'm working on is a 64-bit Windows 7 Enterprise PC. Assuming that I knew what 'configuring cygwin' meant (which I do not), what would I need to do with it?
I do not fully understand the postings as I'm using neither eclipse nor UNIX BUT I read that JGit is rather a reimplementation of than a wrapper for Git. If so, why do I need to install a version of git, which comes with a GUI and works just fine?
The entries in the forums are rather old, but I didn't come up with more recent information.
As it was mentioned in one of the comments in one of the forums, I set the MATLAB path to my remote repository-path. That made no change.
As I am currently setting up the whole source control thing, I do not know yet, which hooks will be needed in the future. Thus using only a limited set of hooks would be an option, but not the most favoured.
Edit:
I just tried
system('git push --all')
this resulted in the execution of my hooks...
- Tobias

Sign in to comment.

Answers (1)

James Otterson
James Otterson on 17 Jan 2019
Uping this question - I am having the same problem, but in regard of my local repo hook. I am using Windows, and using python to run the hook. RStudio, VS Code and command line in Matlab (!git commit -m "message") will run my hooks but commiting code using the Matlab GUI Git interface will bypass all hooks.

Categories

Find more on Source Control Integration in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!