Version Increment X.Y.Z

Folks,

I was wondering if any one had created a button, or set of buttons to increment the three different segments of a standard tiddlywiki version number of the form X.Y.Z major.minor.micro and save it to the source field?

  • This is for plugins or packages
  • perhaps we need to be able also to reset to zero?
  • Perhaps an auto-increment on the micro-version?

I will make and share if not, but I expect this has being done before

I have not, but would love that functionality. That’s exactly how I use version numbers. I usually have two digits for each.

Is this enough?

<$let ver=<<version>> >

What is the version of this TW? It is <<ver>>.

</$let>
  • no, I have one 90% complete, but something is wrong and could be simplified

Snag_1c586f7

Just click to increment each part by 1

  • If > 1 allow reset to zero
  • It would be nice if ctrl-click reset to zero

Here is the code and test macro call, if any one wants to try

  • If the fieldname does not exists it allows you to start with 0.0.0 or 0.1.0
  • I think the problem is when the values/parameters/value refresh
\define set-version(fieldname display-dot:"•")
<$set name=version-field value="$fieldname$" emptyValue="version">
<$list filter="[all[current]has<version-field>get<version-field>]" variable=version-number emptyMessage=<<no-version>> >
<$set name=major value={{{ [<version-number>split[.]first[]] }}}>
<$set name=minor value={{{ [<version-number>split[.]nth[2]] }}}>
<$set name=micro value={{{ [<version-number>split[.]last[]] }}}>
<<set-version-increment major>><<set-version-reset major>>$display-dot$<<set-version-increment minor>><<set-version-reset minor>>$display-dot$<<set-version-increment micro>><<set-version-reset micro>>
</$set></$set></$set>
</$list>
</$set>
\end
\define set-version-increment(variable)
<$set name="lable" value={{{ [<$variable$>] }}}>
<$set name="$variable$" value={{{ [[$variable$]getvariable[]add[1]] }}}>
<$set name=new-version value={{{ [<major>] [<minor>] [<micro>] +[join[.]] }}}>
<$button tooltip={{{ [[Set version to]] [<new-version>] +[join[ ]] }}} actions=<<set-version-actions "$variable$">> >
    <<lable>>
</$button>
</$set></$set></$set>
\end
\define set-version-reset(variable)
<$list filter="[[$variable$]getvariable[]!match[0]]" variable=~>
<$set name="$variable$" value="0">
<$set name=new-version value={{{ [<major>] [<minor>] [<micro>] +[join[.]] }}}>
<$button tooltip={{{ [[Reset $variable$ version to 0, new ]] [<new-version>] +[join[ ]] }}} actions=<<set-version-actions "$variable$">> class="tc-btn-invisible">
    ^^{{$:/core/images/refresh-button}}^^
</$button>
</$set></$set>
</$list>
\end
\define set-version-actions()
<$action-setfield $field=<<version-field>> $value=<<new-version>>/>
\end
\define no-version()
<$button tooltip="New">
  <$action-setfield $field=<<version-field>> $value="0.0.0"/>
   0.0.0
</$button>
<$button  tooltip="First release">
  <$action-setfield $field=<<version-field>> $value="0.1.0"/>
   0.1.0
</$button>
\end
Version <<set-version>>

With TW we use semantic versioning where the elements are X.Y.Z – major.minor.patch

We modified it a bit, since for major we use 5, which is more or less fixed. Since major is reserved for backwards compatibility changes it’s OK that way.

Usually “patch” is for very small changes. That’s different with TW, since we usually have more changes in every new version.