Skip to content

Repository Keyword Substitutions

Kyle Buller edited this page May 24, 2020 · 5 revisions

When repositories are packaged, certain keyword substitutions take place on text files.

Simple replacements

@file-revision@

Turns into the current revision of the file in integer form. e.g. 1234

Note: For Git, this will use the file hash.

@project-revision@

Turns into the highest revision of the entire project in integer form. e.g. 1234

Note: For Git, this will use the commit hash.

@file-hash@

Turns into the hash of the file in hex form. e.g. 106c634df4b3dd4691bf24e148a23e9af35165ea

Note: No replacement will occur for Subversion.

@project-hash@

Turns into the hash of the entire project in hex form. e.g. 106c634df4b3dd4691bf24e148a23e9af35165ea

Note: No replacement will occur for Subversion.

@file-abbreviated-hash@

Turns into the abbreviated hash of the file in hex form. e.g. 106c63

Note: No replacement will occur for Subversion.

@project-abbreviated-hash@

Turns into the abbreviated hash of the entire project in hex form. e.g. 106c63

Note: No replacement will occur for Subversion.

@file-author@

Turns into the last author of the file.

@project-author@

Turns into the last author of the entire project.

@file-date-iso@

Turns into the last changed date (by UTC) of the file in ISO 8601. e.g. 2008-05-01T12:34:56Z

@project-date-iso@

Turns into the last changed date (by UTC) of the entire project in ISO 8601. e.g. 2008-05-01T12:34:56Z

@file-date-integer@

Turns into the last changed date (by UTC) of the file in a readable integer fashion. e.g. 20080501123456

@project-date-integer@

Turns into the last changed date (by UTC) of the entire project in a readable integer fashion. e.g. 2008050123456

@file-timestamp@

Turns into the last changed date (by UTC) of the file in POSIX timestamp. e.g. 1209663296

@project-timestamp@

Turns into the last changed date (by UTC) of the entire project in POSIX timestamp. e.g. 1209663296

@project-version@

Turns into an approximate version of the project. The tag name if on a tag, otherwise it's up to the repo. :SVN returns something like r1234 :Git returns something like v0.1-873fc1 :Mercurial returns something like r1234.

Debug replacements

These occur based on filetype, as they tend to tie into the comment system for the file.

The insides aren't removed so that line numbers stay the same, they just cause them to be commented out.

Lua

--@debug@
  -- Your code here
--@end-debug@

Turns into

--[===[@debug
  -- Your code here
--@end-debug]===]

and

--[===[@non-debug@
  -- Your code here
--@end-non-debug@]===]

Turns into

--@non-debug@
  -- Your code here
--@end-non-debug@

XML

<!--@debug@-->
  <something />
<!--@end-debug@-->

Turns into

<!--@debug@
  <something />
@end-debug@-->

and

<!--@non-debug@
  <something />
@end-non-debug@-->

Turns into

<!--@non-debug@-->
  <something />
<!--@end-non-debug@-->

TOC

#@debug@ and #@end-debug@
Turns into
#@debug@ and #@end-debug@
as well as adding a # to the beginning of each line in-between.

Exclude from packaging

These occur based on filetype, as they tend to tie into the comment system for the file.

Lua

--@do-not-package@
  -- Your code here
--@end-do-not-package@

XML

<!--@do-not-package
  <something />
@end-do-not-package@-->

TOC

#@do-not-package@
## Your files here
#@end-do-not-package@

Removes everything between the @do-not-package@ and @end-do-not-package@ tags including the two tags themselves. This may cause line numbers of subsequent lines to change. The typical usage is at the end of Lua files surrounding debugging functions and other code that end users should never see/execute.

Because of pre-commit hooks, you will still need to comment out the @do-not-package@ and @end-do-not-package@ tags for the relevant file types.

Alpha Replacements

These occur based on filetype, as they tend to tie into the comment system for the file. The insides aren't removed so that line numbers stay the same, they just cause them to be commented out.

These occur from packages created not from tags, i.e. alpha packages. This is useful to put extra debugging information that you want your alpha testers to have, but don't want to appear in release versions.

Lua

--@alpha@
  -- Your code here
--@end-alpha@

and

--[===[@non-alpha@
  -- Your code here
--@end-non-alpha@]===]

Turn into

--[===[@alpha
  -- Your code here
--@end-alpha]===]

and

--@non-alpha@
  -- Your code here
--@end-non-alpha@.

Example:

--@alpha@
  assert(everythingIsOkay())
--@end-alpha@

This would make it so the assert takes place in dev mode and alpha zips, but doesn't bother for releases and betas.

XML

<!--@alpha@-->
  <something />
<!--@end-alpha@-->

and

<!--@non-alpha@-->
  <something />
<!--@end-non-alpha@-->

Turn into

<!--@alpha
  <something />
@end-alpha@-->

and

<!--@non-alpha
  <something />
@end-non-alpha@-->

TOC

#@alpha@
## Your files here
#@end-alpha@

Turns into

#@alpha@
# Your files here
#@end-alpha@

by adding a # to the beginning of each line in-between the tags.

No-lib Replacements

These occur based on filetype, as they tend to tie into the comment system for the file.

The insides aren't removed so that line numbers stay the same, they just cause them to be commented out.

These only occur on packages marked as -nolib.

TOC

#@no-lib-strip@
## Your files here
#@end-no-lib-strip@

Turns into

#@no-lib-strip@
# Your files here
#@end-no-lib-strip@

by adding a # to the beginning of each line in-between the tags.

XML

<!--@no-lib-strip@-->
  <something />>
<!--@end-no-lib-strip@-->

Turns into

<!--@no-lib-strip
  <something />
@end-no-lib-strip@-->