{"id":10709,"date":"2020-07-07T16:00:56","date_gmt":"2020-07-07T16:00:56","guid":{"rendered":"https:\/\/fhug.org.uk\/kb\/?post_type=kb_article&#038;p=10709"},"modified":"2021-11-28T15:40:50","modified_gmt":"2021-11-28T15:40:50","slug":"version-control-and-file-naming-advice","status":"publish","type":"kb_article","link":"https:\/\/www.fhug.org.uk\/kb\/kb-article\/version-control-and-file-naming-advice\/","title":{"rendered":"Plugin Structure, Version Control and File Naming Advice"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>When you start creating Plugins for yourself or for the Plugin Store it really helps to be able to manage the files and the file levels.<\/p>\n<p>These <glwrap>notes<\/glwrap> are intended to help Plugin authors make use of available tools as well as produce consistent Plugins.<\/p>\n<h2>Using a Main Function<\/h2>\n<p>Although not required, it can be a good idea to use a main function for any more complex Plugins that use extra functions, as it allows you to keep the main code at the top of the <glwrap>source<\/glwrap> code.<\/p>\n<p>A simple example would be<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\">function main()\r\nprint(hello())\r\nend\r\n\r\nfunction hello()\r\nreturn 'hello'\r\nend\r\n---------------------------- call main function\r\nmain()<\/pre>\n<h2>The Script Header<\/h2>\n<p>When starting a Plugin it&#8217;s a very good idea to add a Plugin Header which can easily be done from the\u00a0Edit \u00bb Insert Script Header\u00a0option.<\/p>\n<p>In <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>6 This will insert the following to the top of your file.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\">--[[\r\n@Title: \r\n@Author: \r\n@Version: \r\n@LastUpdated: \r\n@Description: \r\n]]<\/pre>\n<p>and in <span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span>7:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\">--[[\r\n@Title: \r\n@Type: Standard\r\n@Author: [YOUR NAME HERE]\r\n@Version: \r\n@Keywords: \r\n@LastUpdated: \r\n@Licence: This plugin is copyright (c) [YEAR AND YOUR NAME HERE] and contributors, and is licensed under the MIT License\r\nwhich is hereby incorporated by reference (see https:\/\/pluginstore.family-historian.co.uk\/fh-plugin-licence)\r\n@Description: \r\n]]<\/pre>\n<p>Consult the <a href=\"https:\/\/pluginstore.family-historian.co.uk\/how-to-submit-a-plugin-to-the-plugin-store\">Plugin Store<\/a> for information on how to complete the fields, but take particular care that:<\/p>\n<ul>\n<li>The\u00a0<code>@Title<\/code>: exactly matches the Plugin name and Plugin File name.<\/li>\n<li>The <code>@LastUpdated:<\/code> <glwrap>date<\/glwrap> matches the date you upload the file to the Plugin Store.<\/li>\n<li>You include the mandatory licence.<\/li>\n<\/ul>\n<p>It&#8217;s a good idea to start with a\u00a0<code>@Version:<\/code>\u00a0number of 0.1.0 for the prototypes and then move up to 1.0.0 when you are ready to release the Plugin to the\u00a0Plugin Store\u00a0as explained in more detail below.<\/p>\n<p>The\u00a0<code>@Description:<\/code> field can span multiple lines; leave a blank line to mark paragraphs.<\/p>\n<p>It is recommended that a log of changes is recorded in the header after the Description, using a format such as:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"lua\">@Description: This plugin provides various date conversions.\r\n@ChangeLog:\r\n@V0.1.0: First prototype attachment to the FHUG Forum.\r\n@V0.1.1: Fixed double date conversion problem.\r\n@V1.0.0: First published release into the Plugin Store.\r\n]]<\/pre>\n<h2>Version Numbers<\/h2>\n<p>Each distinct version of your plugin should have a different version number (as recorded in the @Version: section in your plugin header. It is recommended that you adopt <a href=\"https:\/\/medium.com\/@jameshamann\/a-brief-guide-to-semantic-versioning-c6055d87c90e\">Semantic Versioning<\/a>, which uses a three part numbering system (and is used by<span class=\"fh\" style=\"font-size: 17px !important; line-height: 21.4286px !important;\">\u0192<span style=\"color:#73B262; font-weight: bold;\">h<\/span><\/span> itself):<\/p>\n<ul>\n<li>MAJOR version (incremented when significant new features are released, or changes are released that are not backwards compatible with previous versions \u2013 e.g. file\/data formats in a new version will not be readable in previous versions)<\/li>\n<li>MINOR version (incremented when minor new features are released and there are no backwards-compatibility issues)<\/li>\n<li>PATCH version (incremented when bug fixes are released without new features)<\/li>\n<\/ul>\n<p>Each element of the version number is an integer starting from 0, without leading zeroes.<\/p>\n<p>MAJOR version 0 is reserved for development\/testing before the first release of your plugin. Whenever the MAJOR version is incremented, MINOR AND PATCH levels are initially set to zero.<\/p>\n<p>The authors of very simple plugins may decide not to use the PATCH version component, although it can be very useful for tracking bug-fix releases.<\/p>\n<h2>Version Control<\/h2>\n<p>In the commercial programming world, version control systems are very important as they allow a fairly easy way of tracking changes over time.<\/p>\n<p>There are many different ones and some need a dedicated server. However, there are several systems for Windows which are suitable for home Plugin writers.<\/p>\n<p>A fairly easy to use Windows control system is\u00a0<a href=\"https:\/\/gitforwindows.org\/\">Git for Windows<\/a>, which once installed allows the easy creation of a repository (where all the changed code lives) inside your Plugins folder and allows files to be managed easily using right click on the files in the folder or using Git Gui. There is a nice (if somewhat out of date) guide to getting started with git at\u00a0<a href=\"http:\/\/nathanj.github.io\/gitguide\/tour.html\">NathanJ: An Illustrated Guide to Git<\/a> on Windows; for home use you can ignore the Putty section). And there is an ebook available online:\u00a0 <a href=\"https:\/\/git-scm.com\/book\/en\/v2\">Pro-Git<\/a>.<\/p>\n<p>A version control system will help you keep control of your version numbers.<\/p>\n","protected":false},"template":"","fh_version":[14,15,739],"skill_level":[18,17],"topic":[73],"class_list":["post-10709","kb_article","type-kb_article","status-publish","hentry","fh_version-v5","fh_version-v6","fh_version-v7","skill_level-advanced","skill_level-intermediate","topic-writing-plugins"],"_links":{"self":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/kb_article\/10709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/kb_article"}],"about":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/types\/kb_article"}],"wp:attachment":[{"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/media?parent=10709"}],"wp:term":[{"taxonomy":"fh_version","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/fh_version?post=10709"},{"taxonomy":"skill_level","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/skill_level?post=10709"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.fhug.org.uk\/kb\/wp-json\/wp\/v2\/topic?post=10709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}