Skip to content

Commit 11b3062

Browse files
committed
docs: update formatter docs
1 parent b7fd541 commit 11b3062

File tree

8 files changed

+77
-19
lines changed

8 files changed

+77
-19
lines changed

docs/common_patterns.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Overview:
99
- All releases are done from the master branch.
1010
- Only the master branch is tagged
1111
- Release Candidates are not used
12-
- Any version number not from master includes build metadata to indicate it is not an official release.
12+
- Any version number not from master includes build metadata to indicate it is not an official release.
1313

1414
### Controlling the next version number
1515

docs/formats.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The following built in formats conform to the SemVer spec. They cannot be overri
1717

1818
| Format Token | Substitution |
1919
| ------------- | ------------- |
20-
| `Version` | `{x}.{y}.{z}` |
20+
| `Version` | `{Major}.{Minor}.{Patch}` |
2121
| `VersionPreRelease` | `{Version}-{PreRelease}` |
2222
| `VersionBuildMetaData` | `{Version}+{BuildMetaData}` |
2323
| `VersionPreReleaseBuildMetaData` | `{Version}-{PreRelease}+{BuildMetaData}` |
@@ -30,18 +30,21 @@ The following built in formats conform to the SemVer spec. They cannot be overri
3030
| `Next` | Full Semantic Version |
3131
| `Tag` | Full Semantic Version as a tag (includes the prefix) |
3232
| `TagMessage` | Tag Message |
33-
| `x` | Version major number |
34-
| `z` | Version patch number |
35-
| `y` | Version minor number |
36-
| `br` | Branch name |
37-
| `sh` | Short Hash |
38-
| `hash` | Full Hash |
33+
| `Major` | Version major number |
34+
| `Minor` | Version nimor number |
35+
| `Patch` | Version patch number |
36+
| `Branch` | Branch name |
37+
| `ShortHash` | Short Hash |
38+
| `FullHash` | Full Hash |
3939
| `dd` | Day |
4040
| `mm` | Month |
4141
| `yyyy` | Year |
42-
| `bn` | Build No from build system |
43-
| `tag?` | `true` if this branch is allowed to be tagged; `false` otherwise |
44-
| `pr` | Tag prefix |
42+
| `Tag?` | `true` if this branch is allowed to be tagged; `false` otherwise |
43+
| `Prefix` | Tag prefix |
4544
| `env.XXXX` | Environment Variables |
4645

4746
### Environment Variables
47+
48+
All environment variables are available under a set of formats prefixed with `env.`.
49+
For example `{env.BUILD_NUMBER}` would get the `BUILD_NUMBER` environment variable.
50+
This is most useful for getting information from build systems.

docs/test.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
## A test
2+
3+
<script src="https://cdn.jsdelivr.net/npm/@gitgraph/js"></script>
4+
5+
<div id="master-version-inc-container"></div>
6+
7+
<!-- Use the `GitgraphJS` global variable to create your graph -->
8+
<script>
9+
var withoutHash = GitgraphJS.templateExtend(GitgraphJS.TemplateName.Metro, {
10+
commit: {
11+
message: {
12+
displayHash: false,
13+
displayAuthor: false,
14+
font: "normal 10pt"
15+
},
16+
spacing: 40,
17+
font: "8pt"
18+
},
19+
branch: {
20+
spacing: 40,
21+
label: {
22+
font: "normal 10pt"
23+
}
24+
}
25+
});
26+
27+
function f1() {
28+
// Get the graph container HTML element.
29+
const graphContainer = document.getElementById("master-version-inc-container");
30+
31+
// Instantiate the graph.
32+
const gitgraph = GitgraphJS.createGitgraph(graphContainer, {
33+
template: withoutHash,
34+
});
35+
36+
// Simulate git commands with Gitgraph API.
37+
const master = gitgraph.branch("master");
38+
master
39+
.commit("some code").tag("v4.2.5")
40+
.commit("feat: some more code").tag("v4.3.0")
41+
.commit("fix: a fix")
42+
.commit("feat: a feature").tag("v4.4.0")
43+
44+
//const develop = gitgraph.branch("develop");
45+
//develop.commit("Add TypeScript");
46+
47+
//const aFeature = gitgraph.branch("a-feature");
48+
//aFeature
49+
// .commit("feat: Make it work <-- This will bump the minor version")
50+
// .commit("Make it right")
51+
// .commit("Make it fast");
52+
53+
//develop.merge(aFeature);
54+
//develop.commit("Prepare v1");
55+
56+
//master.merge(develop).tag("v1.0.0");
57+
}
58+
</script>

src/main/scala/net/cardnell/mkver/Formatter.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ object Formatter {
4747
Format("dd", version.date.getDayOfMonth.formatted("00")),
4848
Format("mm", version.date.getMonthValue.formatted("00")),
4949
Format("yyyy", version.date.getYear.toString),
50-
Format("BuildNo", version.buildNo),
5150
Format("Tag?", branchConfig.tag.toString),
5251
Format("TagPrefix", branchConfig.tagPrefix.toString)
5352
) ++ AppConfig.mergeFormats(branchConfig.formats, builtInFormats)

src/main/scala/net/cardnell/mkver/MkVer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ object MkVer {
6464
branch = currentBranch,
6565
commitHashShort = commitInfos.headOption.map(_.shortHash).getOrElse(""),
6666
commitHashFull = commitInfos.headOption.map(_.fullHash).getOrElse(""),
67-
date = LocalDate.now(),
68-
buildNo = sys.env.getOrElse("BUILD_BUILDNUMBER", "TODO")
67+
date = LocalDate.now()
6968
)
7069
}
7170
}

src/main/scala/net/cardnell/mkver/Version.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,4 @@ case class VersionData(major: Int,
4949
branch: String,
5050
commitHashShort: String,
5151
commitHashFull: String,
52-
date: LocalDate,
53-
buildNo: String)
52+
date: LocalDate)

src/test/scala/net/cardnell/mkver/FormatterSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object FormatterSpec extends DefaultRunnableSpec {
2626
assert(Formatter.branchNameToVariable("refs/heads/feat/f1"))(equalTo("feat-f1"))
2727
},
2828
test("should format default variables") {
29-
val versionData = VersionData(1,2,3,4,"feature/f1", "abcd", "abcdefg", LocalDate.now(), "56")
29+
val versionData = VersionData(1,2,3,4,"feature/f1", "abcd", "abcdefg", LocalDate.now())
3030
val branchConfig = BranchConfig(".*", "Version", true, "v", "release {Version}", "RC", Nil, Nil)
3131
val formatter = Formatter(versionData, branchConfig)
3232
assert(formatter.format("{Major}"))(equalTo("1")) &&

src/test/scala/net/cardnell/mkver/MkVerSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ object MkVerSpec extends DefaultRunnableSpec {
5555
),
5656
suite("formatTag")(
5757
testM("should format tag") {
58-
val versionData = VersionData(1,2,3,4,"feature/f1", "abcd", "abcdefg", LocalDate.now(), "56")
59-
val branchConfig = BranchConfig(".*", "Version", true, "v", "release {Version}", "RC", List(Format("Version", "{x}.{y}.{z}")), Nil)
58+
val versionData = VersionData(1,2,3,4,"feature/f1", "abcd", "abcdefg", LocalDate.now())
59+
val branchConfig = BranchConfig(".*", "Version", true, "v", "release {Version}", "RC", List(Format("Version", "{Major}.{Minor}.{Patch}")), Nil)
6060
assertM(formatTag(branchConfig, versionData))(equalTo("v1.2.3"))
6161
}
6262
)

0 commit comments

Comments
 (0)