{"id":15814,"date":"2018-08-13T08:29:21","date_gmt":"2018-08-13T15:29:21","guid":{"rendered":"https:\/\/www.sapien.com\/blog\/?p=15814"},"modified":"2018-08-13T08:29:21","modified_gmt":"2018-08-13T15:29:21","slug":"customizing-git-commands","status":"publish","type":"post","link":"https:\/\/dev.sapien.com\/blog\/2018\/08\/13\/customizing-git-commands\/","title":{"rendered":"Customizing Git Commands"},"content":{"rendered":"<p>We recently added Git support to PrimalScript and, subsequently, to PowerShell Studio. You can <a href=\"https:\/\/www.sapien.com\/blog\/2018\/07\/02\/primalscript-2018-adds-git-version-control-support\/\">read about it here<\/a>.<\/p>\n<p>As promised in the previous post, I will tell you a little bit more about how this works, how you can customize it, and what we have planned for it in the future.<\/p>\n<p>The MS SCC API (Microsoft Source Code Control API) has become old and not very broadly supported, and even Microsoft does not seem to be interested in updating or expanding the interface. However, virtually all source code control systems support a command line interface, so we here at SAPIEN decided to use only command line tools for our new source control interface\u2014Universal Version Control System.<\/p>\n<p>PrimalScript detects a source code control system through the presence of a configuration file. I will use Git as the example throughout this article, but this information easily applies to any command line driven system. The same mechanisms that apply to PrimalScript also apply to PowerShell Studio.<\/p>\n<p>Take a peek at the following folder after you have installed the latest version of PrimalScript or PowerShell Studio: C:\\ProgramData\\SAPIEN\\Version Control Providers<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb.png\" alt=\"image\" width=\"640\" height=\"153\" border=\"0\" \/><\/a><\/p>\n<p>The file &#8216;Git.inf&#8217; is what tells PrimalScript that there is a Source Control Provider named &#8216;Git&#8217;.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-1.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-1.png\" alt=\"image\" width=\"640\" height=\"309\" border=\"0\" \/><\/a><\/p>\n<p>Let\u2019s examine the &#8216;Git.inf&#8217; file to see how things work.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-2.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-2.png\" alt=\"image\" width=\"384\" height=\"108\" border=\"0\" \/><\/a><\/p>\n<p>The \u2018Detect\u2019 section is what tells PrimalScript about the system. The presence of a &#8216;Folder&#8217; named \u2018.git\u2019 indicates that the commands herein apply to any file in a folder containing such a subfolder. \u2018System\u2019 indicates the path to a file that can be used to detect if the system is installed. If you installed Git in a different location than the default, you will need to edit the path.\u00a0&#8216;Name&#8217; is the display name.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-3.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-3.png\" alt=\"image\" width=\"337\" height=\"293\" border=\"0\" \/><\/a><\/p>\n<p>The \u2018Commands\u2019 section lists all available commands for this particular Source Control System. For each command listed here, there must be a corresponding section in the file containing its data. We will use the \u2018Add\u2019 command as an example.<\/p>\n<p>Before we get to that, let&#8217;s take a brief look at the icons used in the user interface. The folder containing &#8216;Git.inf&#8217; also contains a \u2018Git Images\u2019 folder. Its name is derived from the system, so \u2018Git.inf\u2019 implies there is a \u2018Git Images\u2019 folder.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-4.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-4.png\" alt=\"image\" width=\"539\" height=\"480\" border=\"0\" \/><\/a><\/p>\n<p>The name of each command listed corresponds to a png file in the &#8216;Git Images&#8217; folder. These are the images used in PrimalScript\u2019s user interface.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-5.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-5.png\" alt=\"image\" width=\"323\" height=\"96\" border=\"0\" \/><\/a><\/p>\n<p>If you do not like a particular icon we chose, you can easily substitute your own.<\/p>\n<p>Now back to the commands.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-6.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-6.png\" alt=\"image\" width=\"463\" height=\"91\" border=\"0\" \/><\/a><\/p>\n<p>As the name implies, the \u2018Add\u2019 command adds a file to the repository for that current folder. We have received some feedback that users would like to enter their own initial command rather than us just hard-wiring \u2018Initial commit\u2019, so I will show you how to do that.<\/p>\n<p>Each command can have any number of command line instructions which are executed in order, and PrimalScript will wait for each command to complete before executing the next one.<br \/>\nFor the \u2019Add\u2019 command we have two command line instructions:<\/p>\n<p><span style=\"font-family: Consolas;\">git add %FILE%<br \/>\ngit commit -m &#8220;Initial commit&#8221; %FILE%<\/span><\/p>\n<p>Anything in this file bracketed by % characters is considered a macro. The only macro resolved by PrimalScript at this time is %FILE%. It will resolve into the full path of the currently active editor file. Any other macro will be resolved by prompting the user.<\/p>\n<p>Let\u2019s take a look at the \u2018Commit\u2019 command, which already prompts the user for a comment.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-7.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-7.png\" alt=\"image\" width=\"455\" height=\"68\" border=\"0\" \/><\/a><\/p>\n<p>You see a macro %MESSAGE% here. PrimalScript has no idea what that is, so it looks for a value in the inf file \u201cMESSAGE=\u201d and uses the corresponding text to prompt for a value.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"border: 0px currentcolor; background-image: none;\" src=\"https:\/\/i1.wp.com\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/06\/image-5.png?ssl=1\" width=\"518\" height=\"151\" border=\"0\" \/><\/p>\n<p>You can apply that same mechanism to the \u2018Add\u2019 command.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-8.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-8.png\" alt=\"image\" width=\"492\" height=\"110\" border=\"0\" \/><\/a><\/p>\n<p>Save &#8216;Git.inf&#8217; and restart PrimalScript. The inf file is loaded on startup, so any changes made to it will require an application restart.<\/p>\n<p>After saving the inf file and restarting PrimalScript, when you add a file to Git you will be prompted for an initial comment.<\/p>\n<p><a href=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image-9.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px; border: 0px currentcolor; display: inline; background-image: none;\" title=\"image\" src=\"https:\/\/www.sapien.com\/blog\/wp-content\/uploads\/2018\/08\/image_thumb-9.png\" alt=\"image\" width=\"640\" height=\"347\" border=\"0\" \/><\/a><\/p>\n<p>There is currently one caveat\u2014please make sure to make a backup of any modifications you make to the inf file. Since this is under development and subject to change without notice, any time you install an update the inf file will be overwritten and replaced with the standard version.<\/p>\n<p>In the future, we will provide a mechanism for \u2018User\u2019 versus \u2018System\u2019 files. For now, you should assume that any changes made will be erased by an update and will need to be reapplied.<\/p>\n<p>We have quite a number of features and improvements planned. We love to hear from you, so feel free to provide additional feedback or suggestions in the <a href=\"https:\/\/www.sapien.com\/forums\/viewforum.php?f=23\" target=\"_blank\" rel=\"noopener\">feedback section of our forum<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We recently added Git support to PrimalScript and, subsequently, to PowerShell Studio. You can read about it here. As promised in the previous post, I will tell you a little bit more about how this works, how you can customize it, and what we have planned for it in the future. The MS SCC API [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[703,410,21],"tags":[786,1016,37,321],"class_list":["post-15814","post","type-post","status-publish","format-standard","hentry","category-powershell-studio","category-primalscript-software-news","category-software-news","tag-git","tag-powershell-studio","tag-primalscript","tag-version-control"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/15814","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/comments?post=15814"}],"version-history":[{"count":15,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/15814\/revisions"}],"predecessor-version":[{"id":15830,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/posts\/15814\/revisions\/15830"}],"wp:attachment":[{"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/media?parent=15814"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/categories?post=15814"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.sapien.com\/blog\/wp-json\/wp\/v2\/tags?post=15814"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}