OpenInsight Git automatic push to Git repository
Any changes you save in OpenInsight will automatically be pushed out to Git. For example, when you save a stored procedure in the System Editor, the updated source code will be automatically pushed to your Git repository.
This automatic push will occur for all repository entities when using their default editing tool. It will not work if you update an entity by bypassing the repository function. For example, if you edit a procedure in the System Editor by opening a record in the SYSPROCS table, making changes then saving the changes. This method bypasses the REPOSITORY function and also the automatic push to Git.
So let’s see how this automatic push works. Open the System Editor and open a stored procedure (in this case it is called JOB).
Change line 4 from Sean FitzSimons to Robert Catalano
Insert a new line at line 6 like this:
* Modified 1 DEC 2017
Then either Save or Save and Compile the change. You will not see any difference in OpenInsight, but your changes have been automatically pushed to Git. Automatically pushing the changes for you makes working with Git much easier.
Figure 63 – Update to stored procedure JOB in OpenInsight on win10test3
Now go back to Windows Explorer and navigate to C:\Revsoft\Git_win10test3\STAR\oirepository\STPROC and edit the JOB.txt file in Notepad. You will see your modified and newly added lines near the top.
Figure 64 – Change automatically pushed to Git
It does not matter how many times you save changes in OpenInsight, Git will only remember the source code as of the last save you made in OpenInsight. To get Git to “snapshot” the code as at a particular time, you need to commit your changes to Git.
From the OpenInsight IDE go to Git, select Git Commit… The commit window will look like this.
Figure 65 – Committing new changes to Git
Git knows that the JOB procedure has changed. Move this file into the staging area and enter a commit comment such as:
Changed program author
Then, hit the Commit button.
You now have two snapshots of the source code for JOB. That is, versions when:
1. You first pushed out the source code from OpenInsight and committed the changes and,
2. When you edited the program in the System Editor and committed the changes
To see a history of changes for this file in Git, navigate to the C:\Revsoft\Git_win10test3\STAR\oirepository\STPROC directory and right-click on the JOB.txt file.
Then, from the context menu, select Git Extensions and then, File History.
Figure 66 – Viewing the history of a file in Git
This will open the Git Extensions history window.
Figure 67 – Git Extensions file history window
You can see that there have been multiple commits for this file. You can view the source code as it was at each commit, and you can even compare the changes between each commit.
This is one of the powerful features of Git. It lets you view previous versions of a procedure and compare them to see what changed between each version, who made the change and when the change occurred.
Would you like to revert back to a previous version of a procedure, no problem. Just select the previous version you want, copy the code, and paste it into the editor in OpenInsight. Done. Also, there is no need to worry about losing the current version of the code in OpenInsight. As long as it has been committed to Git, you will always have a snapshot of the code as it was at that point in time.
Even if you delete a procedure from OpenInsight and commit the delete to Git, all is not lost. Git will always remember the snapshots of files, even after they have been deleted. Therefore, you can always get your source back. The only catch is that you must commit your changes to Git on a regular basis because Git only remembers committed files.
Remember, commit early and commit often!