MCPcopy
hub / github.com/ampproject/amphtml / getVersion

Function getVersion

build-system/compile/internal-version.js:66–90  ·  view source on GitHub ↗

* Generates the AMP version number. * * Version numbers are determined using the following algorithm: * - Count the number ( ) of cherry-picked commits on this branch, including * commits not on the main branch . If this branch only contains new commits * that are not cherry-picked, then

(ref = 'HEAD')

Source from the content-addressed store, hash-verified

64 * @return {string} AMP version number (always 13 digits long)
65 */
66function getVersion(ref = 'HEAD') {
67 if (argv.version_override) {
68 const version = String(argv.version_override);
69 if (!/^\d{13}$/.test(version)) {
70 throw new Error('--version_override only accepts a 13-digit version');
71 }
72 return version;
73 }
74
75 const numberOfCherryPicks = gitCherryMain(ref).length;
76 if (numberOfCherryPicks > 999) {
77 throw new Error(
78 `This branch has ${numberOfCherryPicks} cherry-picks, which is more ` +
79 'than 999, the maximum allowed number of cherry-picks! Please make ' +
80 'sure your local main branch is up to date.'
81 );
82 }
83
84 const lastCommitFormattedTime = gitCommitFormattedTime(
85 `${ref}~${numberOfCherryPicks}`
86 ).slice(0, -2);
87
88 const numberOfCherryPicksStr = String(numberOfCherryPicks).padStart(3, '0');
89 return `${lastCommitFormattedTime}${numberOfCherryPicksStr}`;
90}
91
92// Used to e.g. references the ads binary from the runtime to get version lock.
93const VERSION = getVersion();

Callers 2

cutNightlyBranchFunction · 0.85

Calls 4

gitCherryMainFunction · 0.85
gitCommitFormattedTimeFunction · 0.85
StringFunction · 0.50
testMethod · 0.45

Tested by

no test coverage detected