This all depends greatly on your workflow and Git setup, but for this example suppose we have a local Git repository with the "master"/"main" branch and a "dev" branch. We want different versions of an addin registered in EViews depending on which branch is currently active, and we can use Git hooks to automatically switch that registration whenever we switch between branches. And just to make our lives more interesting, I'll use COM automation to interact with EViews, which will let us change the addin registration for a running instance of EViews (so we don't need to restart EViews).
I assume the Git command-line tools are available; I constructed this example for a "Git for Windows" installation. From the Git repository root directory, in subdirectory ".git\hooks\", we can create a script that will trigger whenever we checkout a branch. Since I've injected COM into this example, I'll actually use a pair of scripts. Git will call the first script, which will call the second script, which will interact with EViews to register the desired addin. The first script will determine which version of the addin we want to register based on whether we've switched to the "dev" branch or not. Mechanically, this first script is just picking a command that will be executed in EViews. The real payload of the script are the "addin(proc=foo) dev_version.prg" and "addin(proc=foo) prod_version.prg" strings, which naturally would need to be altered to reflect the true details of the addin.
.git\hooks\post-checkout
Code: Select all
#!/bin/bash
branchName=$(git branch --show-current)
if [ $3 = '1' ]; then
if [ $branchName = 'dev' ]; then
cmd="addin(proc=foo) dev_version.prg"
else
cmd="addin(proc=foo) prod_version.prg"
fi
cscript.exe //NoLogo $(dirname "$0")/post-checkout.vbs "$cmd"
fi
The second script takes care of the details of executing the chosen command, i.e., registering an addin, in EViews via COM.
.git\hooks\post-checkout.vbs
Code: Select all
doExit = False
Set mgr = CreateObject("EViews.Manager")
Set app = mgr.GetApplication(2)
If app Is Nothing Then
Set app = mgr.GetApplication(0)
doExit = True
End If
app.Run(WScript.Arguments.Item(0))
If doExit Then
app.Run("exit")
End If
The net result of these example scripts is to modify a fictitious global addin named "foo". If we switch to the "dev" branch then the addin is associated with the dev_version.prg program, but if we switch to any other branch then the addin is associated with the prod_version.prg program.