wip: improve update-specs script

This commit is contained in:
2026-01-11 09:07:34 +00:00
parent 1eab53b7ba
commit 164729b57e
27 changed files with 998 additions and 857 deletions

View File

@@ -38,7 +38,7 @@ bun run format
bun run format:check
# Update specs from upstream (fetches from github.com/jimeh/common-flow)
bun run update
bun run update-specs
```
The site is built to `docs/` for GitHub Pages hosting.

View File

@@ -16,6 +16,7 @@
"rehype-stringify": "^10.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2",
"semver": "^7.7.3",
"unified": "^11.0.5",
},
"devDependencies": {
@@ -23,6 +24,8 @@
"@eslint/js": "^9.39.2",
"@tailwindcss/typography": "^0.5.19",
"@tailwindcss/vite": "^4.1.18",
"@types/bun": "^1.3.5",
"@types/semver": "^7.7.1",
"eslint": "^9.39.2",
"eslint-plugin-astro": "^1.5.0",
"prettier": "^3.7.4",
@@ -348,6 +351,8 @@
"@trysound/sax": ["@trysound/sax@0.2.0", "", {}, "sha512-L7z9BgrNEcYyUYtF+HaEfiS5ebkh9jXqbszz7pC0hRBPaatV0XjSD3+eHrpqFemQfgwiFF0QPIarnIihIDn7OA=="],
"@types/bun": ["@types/bun@1.3.5", "", { "dependencies": { "bun-types": "1.3.5" } }, "sha512-RnygCqNrd3srIPEWBd5LFeUYG7plCoH2Yw9WaZGyNmdTEei+gWaHqydbaIRkIkcbXwhBT94q78QljxN0Sk838w=="],
"@types/debug": ["@types/debug@4.1.12", "", { "dependencies": { "@types/ms": "*" } }, "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ=="],
"@types/estree": ["@types/estree@1.0.8", "", {}, "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w=="],
@@ -366,6 +371,8 @@
"@types/sax": ["@types/sax@1.2.7", "", { "dependencies": { "@types/node": "*" } }, "sha512-rO73L89PJxeYM3s3pPPjiPgVVcymqU490g0YO5n5By0k2Erzj6tay/4lr1CHAAU4JyOWd1rpQ8bCf6cZfHU96A=="],
"@types/semver": ["@types/semver@7.7.1", "", {}, "sha512-FmgJfu+MOcQ370SD0ev7EI8TlCAfKYU+B4m5T3yXc1CiRN94g/SZPtsCkk506aUDtlMnFZvasDwHHUcZUEaYuA=="],
"@types/unist": ["@types/unist@3.0.3", "", {}, "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q=="],
"@types/yauzl": ["@types/yauzl@2.10.3", "", { "dependencies": { "@types/node": "*" } }, "sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q=="],
@@ -458,6 +465,8 @@
"buffer-crc32": ["buffer-crc32@0.2.13", "", {}, "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ=="],
"bun-types": ["bun-types@1.3.5", "", { "dependencies": { "@types/node": "*" } }, "sha512-inmAYe2PFLs0SUbFOWSVD24sg1jFlMPxOjOSSCYqUgn4Hsc3rDc7dFvfVYjFPNHtov6kgUeulV4SxbuIV/stPw=="],
"callsites": ["callsites@3.1.0", "", {}, "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="],
"camelcase": ["camelcase@8.0.0", "", {}, "sha512-8WB3Jcas3swSvjIeA2yvCJ+Miyz5l1ZmB6HFb9R1317dt9LCQoswg/BGrmAmkWVEszSrrg4RwmO46qIm2OEnSA=="],

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <div class="flex flex-col items-center justify-center min-h-screen p-8"> <div class="text-center"> <h1 class="text-[8rem] sm:text-[12rem] font-display font-bold leading-none
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <div class="flex flex-col items-center justify-center min-h-screen p-8"> <div class="text-center"> <h1 class="text-[8rem] sm:text-[12rem] font-display font-bold leading-none
text-gray-300 dark:text-neutral-700">
404
</h1> <p class="text-xl mb-2 text-gray-600 dark:text-neutral-400">

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
translate-y-[-100%] transition-transform duration-300
backdrop-blur-xl bg-gray-50/85 dark:bg-neutral-950/85"> <div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between"> <!-- Logo / Title + Version --> <div class="flex items-center gap-3"> <a href="#hero" class="flex items-center gap-3 no-underline
text-gray-950 dark:text-neutral-50

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
translate-y-[-100%] transition-transform duration-300
backdrop-blur-xl bg-gray-50/85 dark:bg-neutral-950/85"> <div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between"> <!-- Logo / Title + Version --> <div class="flex items-center gap-3"> <a href="#hero" class="flex items-center gap-3 no-underline
text-gray-950 dark:text-neutral-50

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
translate-y-[-100%] transition-transform duration-300
backdrop-blur-xl bg-gray-50/85 dark:bg-neutral-950/85"> <div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between"> <!-- Logo / Title + Version --> <div class="flex items-center gap-3"> <a href="#hero" class="flex items-center gap-3 no-underline
text-gray-950 dark:text-neutral-50

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
translate-y-[-100%] transition-transform duration-300
backdrop-blur-xl bg-gray-50/85 dark:bg-neutral-950/85"> <div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between"> <!-- Logo / Title + Version --> <div class="flex items-center gap-3"> <a href="#hero" class="flex items-center gap-3 no-underline
text-gray-950 dark:text-neutral-50

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
translate-y-[-100%] transition-transform duration-300
backdrop-blur-xl bg-gray-50/85 dark:bg-neutral-950/85"> <div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between"> <!-- Logo / Title + Version --> <div class="flex items-center gap-3"> <a href="#hero" class="flex items-center gap-3 no-underline
text-gray-950 dark:text-neutral-50

View File

@@ -8,7 +8,7 @@
document.documentElement.classList.add("dark");
}
})();
</script><link rel="stylesheet" href="/_astro/index.DF_wxGza.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
</script><link rel="stylesheet" href="/_astro/index.Ds9Y8AeZ.css"></head> <body class="min-h-screen"> <header id="site-header" class="fixed top-0 inset-x-0 z-50 border-b border-transparent
translate-y-[-100%] transition-transform duration-300
backdrop-blur-xl bg-gray-50/85 dark:bg-neutral-950/85"> <div class="max-w-6xl mx-auto px-4 sm:px-6 h-16 flex items-center justify-between"> <!-- Logo / Title + Version --> <div class="flex items-center gap-3"> <a href="#hero" class="flex items-center gap-3 no-underline
text-gray-950 dark:text-neutral-50

View File

@@ -10,7 +10,7 @@
"lint": "eslint .",
"format": "prettier --write .",
"format:check": "prettier --check .",
"update": "bun scripts/update-specs.ts",
"update-specs": "bun scripts/update-specs.ts",
"astro": "astro"
},
"dependencies": {
@@ -25,6 +25,7 @@
"rehype-stringify": "^10.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2",
"semver": "^7.7.3",
"unified": "^11.0.5"
},
"devDependencies": {
@@ -32,6 +33,8 @@
"@eslint/js": "^9.39.2",
"@tailwindcss/typography": "^0.5.19",
"@tailwindcss/vite": "^4.1.18",
"@types/bun": "^1.3.5",
"@types/semver": "^7.7.1",
"eslint": "^9.39.2",
"eslint-plugin-astro": "^1.5.0",
"prettier": "^3.7.4",

View File

@@ -1,39 +1,85 @@
/**
* Fetches spec documents and diagrams from the common-flow GitHub repo
* and writes them to the appropriate locations for Astro to consume.
*
* Versions are discovered from git tags and filtered based on config.
*/
import * as fs from "node:fs";
import * as path from "node:path";
import * as semver from "semver";
import { $ } from "bun";
import { config } from "../src/config";
const config = {
currentVersion: "1.0.0-rc.5",
versions: [
"1.0.0-rc.5",
"1.0.0-rc.4",
"1.0.0-rc.3",
"1.0.0-rc.2",
"1.0.0-rc.1",
],
update: {
urlTemplate:
"https://github.com/jimeh/common-flow/raw/{{version}}/{{file}}",
bodyTemplate: `---
const updateConfig = {
bodyTemplate: `---
title: {{title}}
version: {{version}}
---
{{content}}`,
imgTemplate:
'<img src="/spec/{{file}}" alt="{{title}} diagram" width="100%" />',
outputDir: "src/content/spec",
publicDir: "public/spec",
files: {
document: "common-flow.md",
diagram: "common-flow.svg",
},
},
outputDir: "src/content/spec",
publicDir: "public/spec",
};
/**
* Fetch all tags from the GitHub repository.
*/
async function fetchTags(repository: string): Promise<string[]> {
const repoUrl = `https://github.com/${repository}.git`;
console.log(`Fetching tags from ${repoUrl}...`);
try {
const result = await $`git ls-remote --tags ${repoUrl}`.text();
return result
.split("\n")
.filter(Boolean)
.map((line: string) => line.match(/refs\/tags\/(.+)$/)?.[1])
.filter(
(tag: string | undefined): tag is string =>
tag !== undefined && !tag.endsWith("^{}"),
);
} catch (error) {
throw new Error(
`Failed to fetch tags: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
/**
* Get the prerelease type of a version (e.g., "rc", "draft", or null for
* stable).
*/
function getPrereleaseType(version: string): string | null {
const prerelease = semver.prerelease(version);
if (!prerelease) return null;
return String(prerelease[0]);
}
/**
* Filter tags based on discovery configuration.
* Stable versions are always included; prereleases only if their type is in
* the includePrereleaseTypes list.
*/
function filterVersions(tags: string[]): string[] {
const { includePrereleaseTypes, excludeVersions } = config.update.discovery;
return tags.filter((tag) => {
// Must be valid semver
if (!semver.valid(tag)) return false;
// Check explicit exclusions
if (excludeVersions.includes(tag)) return false;
// Stable versions are always included
const prereleaseType = getPrereleaseType(tag);
if (prereleaseType === null) return true;
// Prereleases only if their type is in the list
return includePrereleaseTypes.includes(prereleaseType);
});
}
function buildFileUrl(
fileType: "document" | "diagram",
version: string,
@@ -65,19 +111,36 @@ function writeFile(filePath: string, content: string, comment = ""): void {
console.log(` - ${filePath}${comment}`);
}
function removeAllSpecs(): void {
console.log("\nRemoving existing spec files:");
/**
* Remove spec files for versions not in the provided list.
* Files for versions in the list are left alone (they'll be overwritten).
*/
function removeStaleSpecs(versionsToKeep: string[]): void {
const keepSet = new Set(versionsToKeep);
let removedAny = false;
for (const dir of [config.update.outputDir, config.update.publicDir]) {
if (fs.existsSync(dir)) {
const files = fs.readdirSync(dir);
for (const file of files) {
for (const dir of [updateConfig.outputDir, updateConfig.publicDir]) {
if (!fs.existsSync(dir)) continue;
const files = fs.readdirSync(dir);
for (const file of files) {
// Extract version from filename (e.g., "1.0.0-rc.1.md" -> "1.0.0-rc.1")
const version = path.basename(file, path.extname(file));
if (!keepSet.has(version)) {
if (!removedAny) {
console.log("\nRemoving stale spec files:");
removedAny = true;
}
const filePath = path.join(dir, file);
fs.unlinkSync(filePath);
console.log(` ${filePath}`);
}
}
}
if (!removedAny) {
console.log("\nNo stale spec files to remove.");
}
}
interface Spec {
@@ -104,16 +167,8 @@ async function fetchSpec(version: string): Promise<Spec> {
// Extract title from first line (after version replacement)
const title = document.split("\n", 1)[0];
// If diagram exists, inject image tag after the title
if (diagram) {
const imgTag = config.update.imgTemplate
.replace("{{file}}", `${version}.svg`)
.replace("{{title}}", title);
document = document.replace(/^(.*\n=+\n)/, `$1\n${imgTag}\n`);
}
// Build body with frontmatter
const body = config.update.bodyTemplate
const body = updateConfig.bodyTemplate
.replace("{{content}}", document)
.replace("{{title}}", title)
.replace("{{version}}", version);
@@ -127,21 +182,38 @@ async function fetchSpec(version: string): Promise<Spec> {
}
async function main(): Promise<void> {
removeAllSpecs();
// 1. Discover and filter versions
const tags = await fetchTags(config.update.repository);
console.log(`Found ${tags.length} tags`);
console.log("\nFetching configured spec versions:");
const filtered = filterVersions(tags);
const sorted = semver.rsort([...filtered]);
for (const version of config.versions) {
console.log(`\nIncluded ${sorted.length} versions after filtering:`);
console.log(` ${sorted.join(", ")}`);
if (sorted.length === 0) {
console.error("\nNo versions to process. Exiting.");
process.exit(1);
}
// 2. Remove spec files for versions no longer in the list
removeStaleSpecs(sorted);
// 3. Fetch specs for all versions
console.log("\nFetching spec documents:");
for (const version of sorted) {
try {
const spec = await fetchSpec(version);
// Write markdown file to content collection
const mdPath = path.join(config.update.outputDir, `${version}.md`);
const mdPath = path.join(updateConfig.outputDir, `${version}.md`);
writeFile(mdPath, spec.body);
// Write SVG diagram to public directory
if (spec.diagram) {
const svgPath = path.join(config.update.publicDir, `${version}.svg`);
const svgPath = path.join(updateConfig.publicDir, `${version}.svg`);
writeFile(svgPath, spec.diagram);
}
} catch (error) {

View File

@@ -6,9 +6,10 @@ import { config } from "../config";
interface Props {
version: string;
versions: string[];
}
const { version } = Astro.props;
const { version, versions } = Astro.props;
const navItems = [
{ id: "about", label: "About", icon: "heroicons:information-circle" },
@@ -39,10 +40,7 @@ const navItems = [
</span>
</a>
<div class="hidden md:block">
<VersionSelector
currentVersion={version}
versions={Array.from(config.versions)}
/>
<VersionSelector currentVersion={version} versions={versions} />
</div>
</div>
@@ -104,10 +102,7 @@ const navItems = [
>
<div class="px-4 py-3 space-y-1 text-center">
<div class="py-2 flex justify-center">
<VersionSelector
currentVersion={version}
versions={Array.from(config.versions)}
/>
<VersionSelector currentVersion={version} versions={versions} />
</div>
{
navItems.map((item) => (

View File

@@ -6,10 +6,11 @@ import { config } from "../config";
interface Props {
version: string;
versions: string[];
svgPath: string;
}
const { version, svgPath } = Astro.props;
const { version, versions, svgPath } = Astro.props;
---
<section
@@ -42,10 +43,7 @@ const { version, svgPath } = Astro.props;
px-6 py-4 animate-fade-in-down"
>
<div class="flex items-center gap-3">
<VersionSelector
currentVersion={version}
versions={Array.from(config.versions)}
/>
<VersionSelector currentVersion={version} versions={versions} />
</div>
<div class="flex items-center gap-2">
<ThemeToggle />

View File

@@ -12,16 +12,8 @@ import { Icon } from "astro-icon/components";
hover:bg-gray-100 dark:hover:bg-neutral-800"
aria-label="Toggle theme"
>
<Icon
name="heroicons:sun"
data-theme-icon="light"
class="hidden w-5 h-5"
/>
<Icon
name="heroicons:moon"
data-theme-icon="dark"
class="hidden w-5 h-5"
/>
<Icon name="heroicons:sun" data-theme-icon="light" class="hidden w-5 h-5" />
<Icon name="heroicons:moon" data-theme-icon="dark" class="hidden w-5 h-5" />
<Icon
name="heroicons:computer-desktop"
data-theme-icon="auto"

View File

@@ -13,23 +13,25 @@ export const config = {
url: "https://creativecommons.org/licenses/by/4.0/",
},
currentVersion: "1.0.0-rc.5",
versions: [
"1.0.0-rc.5",
"1.0.0-rc.4",
"1.0.0-rc.3",
"1.0.0-rc.2",
"1.0.0-rc.1",
],
// Optional override for current version (null = auto-detect from specs)
currentVersionOverride: null as string | null,
// Used by update script
update: {
repository: "jimeh/common-flow",
urlTemplate:
"https://github.com/jimeh/common-flow/raw/{{version}}/{{file}}",
files: {
document: "common-flow.md",
diagram: "common-flow.svg",
},
// Version discovery settings
discovery: {
// Prerelease types to include (stable versions are always included)
includePrereleaseTypes: ["rc"] as string[],
// Explicit versions to exclude
excludeVersions: [] as string[],
},
},
} as const;

View File

@@ -2,7 +2,12 @@ import { defineCollection, z } from "astro:content";
import { glob } from "astro/loaders";
const spec = defineCollection({
loader: glob({ pattern: "**/*.md", base: "./src/content/spec" }),
loader: glob({
pattern: "**/*.md",
base: "./src/content/spec",
// Use filename (without extension) as ID to preserve version strings
generateId: ({ entry }) => entry.replace(/\.md$/, ""),
}),
schema: z.object({
title: z.string(),
version: z.string(),

View File

@@ -2,12 +2,11 @@
title: Git Common-Flow 1.0.0-rc.1
version: 1.0.0-rc.1
---
Git Common-Flow 1.0.0-rc.1
==============================
# Git Common-Flow 1.0.0-rc.1
<img src="/spec/1.0.0-rc.1.svg" alt="Git Common-Flow 1.0.0-rc.1 diagram" width="100%" />
## Summary
Summary
-------
Common-Flow is an attempt to gather a sensible selection of the most common
usage patterns of git into a single and concise specification. It is based on
@@ -19,7 +18,8 @@ TL;DR: Common-Flow is basically GitHub Flow with the addition of versioned
releases, maintenance releases for old versions, and without the requirement to
deploy to production all the time.
## Terminology
Terminology
-----------
- **Master Branch** - Must always have passing tests, is considered bleeding
edge, and must be named `master`.
@@ -43,129 +43,131 @@ deploy to production all the time.
commit and release tag are on a maintenance branch instead of the master
branch.
## Git Common-Flow Specification (Common-Flow)
Git Common-Flow Specification (Common-Flow)
-------------------------------------------
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
1. The Master Branch
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST be considered bleeding edge.
3. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch SHOULD always be in a "as near as possible ready for
release/production" state to reduce the friction of creating a new
release.
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST be considered bleeding edge.
3. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch SHOULD always be in a "as near as possible ready for
release/production" state to reduce the friction of creating a new
release.
2. Changes
1. Changes MUST be performed on a separate branch that SHOULD be referred to
as a "change branch". All change branches MUST have descriptive names. It
is RECOMMENDED that you commit often locally, and you SHOULD regularly
push your work to the same named branch on the remote server.
2. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target branch", typically this will be the same
as the source branch.
3. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch. To be clear you MUST NOT merge a source branch into a
change branch.
4. After rebasing a change branch on top of its source branch you MUST push
the change branch to the remote server. This will require you do a force
push, and you SHOULD use the "--force-with-lease" git push option.
5. To merge a change branch into its merge target branch, you MUST open a
"pull request" (or equivalent) so others can review and approve your
changes.
6. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
7. To get feedback, help, or generally just discuss a change branch with
others, it is RECOMMENDED you do this by creating a pull request and
discuss the changes with others there.
1. Changes MUST be performed on a separate branch that SHOULD be referred to
as a "change branch". All change branches MUST have descriptive names. It
is RECOMMENDED that you commit often locally, and you SHOULD regularly
push your work to the same named branch on the remote server.
2. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target branch", typically this will be the same
as the source branch.
3. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch. To be clear you MUST NOT merge a source branch into a
change branch.
4. After rebasing a change branch on top of its source branch you MUST push
the change branch to the remote server. This will require you do a force
push, and you SHOULD use the "--force-with-lease" git push option.
5. To merge a change branch into its merge target branch, you MUST open a
"pull request" (or equivalent) so others can review and approve your
changes.
6. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
7. To get feedback, help, or generally just discuss a change branch with
others, it is RECOMMENDED you do this by creating a pull request and
discuss the changes with others there.
3. Git Best Practices
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
documentation:
<https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project>
2. You SHOULD always use "--force-with-lease" when doing a force push. The
plain "--force" option is dangerous and destructive. More
information:
<https://developer.atlassian.com/blog/2015/04/force-with-lease/>
3. You SHOULD understand and be comfortable with
rebasing: <https://git-scm.com/book/en/v2/Git-Branching-Rebasing>
4. It is RECOMMENDED that you always do "git pull --rebase" instead of "git
pull" to avoid unnecessary merge commits. You can make this the default
behavior of "git pull" with "git config --global pull.rebase true".
5. It is RECOMMENDED that all branches be merged using "git merge --no-ff".
This makes sure the reference to the original branch is kept in the commits,
allows one to revert a merge by reverting a single merge commit, and creates
a merge commit to mark the integration of the branch with master.
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
documentation:
<https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project>
2. You SHOULD always use "--force-with-lease" when doing a force push. The
plain "--force" option is dangerous and destructive. More
information:
<https://developer.atlassian.com/blog/2015/04/force-with-lease/>
3. You SHOULD understand and be comfortable with
rebasing: <https://git-scm.com/book/en/v2/Git-Branching-Rebasing>
4. It is RECOMMENDED that you always do "git pull --rebase" instead of "git
pull" to avoid unnecessary merge commits. You can make this the default
behavior of "git pull" with "git config --global pull.rebase true".
5. It is RECOMMENDED that all branches be merged using "git merge --no-ff".
This makes sure the reference to the original branch is kept in the commits,
allows one to revert a merge by reverting a single merge commit, and creates
a merge commit to mark the integration of the branch with master.
4. Versioning
1. The project MUST have its version hard-coded somewhere in the
code-base. It is RECOMMENDED that this is done in a file called "VERSION"
located in the root of the project.
2. If you are using a "VERSION" file in the root of the project, this MUST
only contain the exact version string.
3. The version string SHOULD follow the Semantic Versioning
(<http://semver.org/>) format. Use of Semantic Versioning is OPTIONAL,
but the version string MUST NOT have a "v" prefix. For example "v2.11.4"
is bad, and "2.11.4" is good.
1. The project MUST have its version hard-coded somewhere in the
code-base. It is RECOMMENDED that this is done in a file called "VERSION"
located in the root of the project.
2. If you are using a "VERSION" file in the root of the project, this MUST
only contain the exact version string.
3. The version string SHOULD follow the Semantic Versioning
(<http://semver.org/>) format. Use of Semantic Versioning is OPTIONAL,
but the version string MUST NOT have a "v" prefix. For example "v2.11.4"
is bad, and "2.11.4" is good.
5. Releases
1. To create a new release, you MUST create a "version bump" commit directly
on the master branch which changes the hard-coded version value of the
project. The version bump commit MUST have a git tag created on it and
named as the exact version string.
2. A version bump commit MUST have a commit message title of "Bump version
to VERSION". For example, if the new version string is "2.11.4", the
first line of the commit message MUST read: "Bump version to 2.11.4"
3. The release tag on the version bump commit MUST be named exactly the same
as the version string. The tag name can OPTIONALLY be prefixed with
"v". For example the tag name can be either "2.11.4" or "v2.11.4".
4. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
5. If you use annotated release tags, the first line of the annotation MUST
read "Release VERSION". For example for version "2.11.4" the first line
of the tag annotation would read "Release 2.11.4". The second line must
be blank, and the changelog MUST start on the third line.
1. To create a new release, you MUST create a "version bump" commit directly
on the master branch which changes the hard-coded version value of the
project. The version bump commit MUST have a git tag created on it and
named as the exact version string.
2. A version bump commit MUST have a commit message title of "Bump version
to VERSION". For example, if the new version string is "2.11.4", the
first line of the commit message MUST read: "Bump version to 2.11.4"
3. The release tag on the version bump commit MUST be named exactly the same
as the version string. The tag name can OPTIONALLY be prefixed with
"v". For example the tag name can be either "2.11.4" or "v2.11.4".
4. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
5. If you use annotated release tags, the first line of the annotation MUST
read "Release VERSION". For example for version "2.11.4" the first line
of the tag annotation would read "Release 2.11.4". The second line must
be blank, and the changelog MUST start on the third line.
6. Bug Fixes & Rollback
1. You MUST NOT under any circumstances force push to the master branch.
2. If a change branch which has been merged in to the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged in to master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
1. You MUST NOT under any circumstances force push to the master branch.
2. If a change branch which has been merged in to the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged in to master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
7. Maintenance Releases
1. Any branch that has a name starting with "stable-" SHOULD be referred to
as a "maintenance branch".
2. Maintenance branches are used for managing new releases of older
versions. Typically this is used to provide security updates for older
versions when the master branch has moved on to a point that a new
release for the old version cannot be made from the master branch.
3. A "maintenance release" is identical to a regular release, except the
version bump commit and the release tag are placed on the maintenance
branch instead of on the master branch.
4. A maintenance branch SHOULD follow a "stable-X.Y" naming pattern, where
"X" is the MAJOR version and "Y" is the minor version.
5. A maintenance branch MUST be created from the relevant release tag. For
example if there is a security fix for all 2.9.x releases, the latest of
which is "2.9.7", we create a new branch called "stable-2.9" off of the
"2.9.7" release tag. The security fix release will then end up being
version "2.9.8".
6. When working on a maintenance release, the relevant maintenance branch
MUST be thought of as the master branch for that maintenance work.
7. Changes in a maintenance branch SHOULD typically come from work being
done against the master branch. Meaning changes SHOULD only trickle
downwards from the master branch. If a change needs to trickle back up
into the master branch, that work should have happened against the master
branch in the first place.
1. Any branch that has a name starting with "stable-" SHOULD be referred to
as a "maintenance branch".
2. Maintenance branches are used for managing new releases of older
versions. Typically this is used to provide security updates for older
versions when the master branch has moved on to a point that a new
release for the old version cannot be made from the master branch.
3. A "maintenance release" is identical to a regular release, except the
version bump commit and the release tag are placed on the maintenance
branch instead of on the master branch.
3. A maintenance branch SHOULD follow a "stable-X.Y" naming pattern, where
"X" is the MAJOR version and "Y" is the minor version.
4. A maintenance branch MUST be created from the relevant release tag. For
example if there is a security fix for all 2.9.x releases, the latest of
which is "2.9.7", we create a new branch called "stable-2.9" off of the
"2.9.7" release tag. The security fix release will then end up being
version "2.9.8".
5. When working on a maintenance release, the relevant maintenance branch
MUST be thought of as the master branch for that maintenance work.
6. Changes in a maintenance branch SHOULD typically come from work being
done against the master branch. Meaning changes SHOULD only trickle
downwards from the master branch. If a change needs to trickle back up
into the master branch, that work should have happened against the master
branch in the first place.
## About
About
-----
The Git Common-Flow specification is authored
by [Jim Myhrberg](http://jimeh.me).
@@ -173,6 +175,7 @@ by [Jim Myhrberg](http://jimeh.me).
If you'd like to leave feedback,
please [open an issue on GitHub](https://github.com/jimeh/common-flow/issues).
## License
License
-------
[Creative Commons - CC BY 3.0](http://creativecommons.org/licenses/by/3.0/)

View File

@@ -2,12 +2,11 @@
title: Git Common-Flow 1.0.0-rc.2
version: 1.0.0-rc.2
---
Git Common-Flow 1.0.0-rc.2
==============================
# Git Common-Flow 1.0.0-rc.2
<img src="/spec/1.0.0-rc.2.svg" alt="Git Common-Flow 1.0.0-rc.2 diagram" width="100%" />
## Summary
Summary
-------
Common-Flow is an attempt to gather a sensible selection of the most common
usage patterns of git into a single and concise specification. It is based on
@@ -19,7 +18,8 @@ TL;DR: Common-Flow is basically GitHub Flow with the addition of versioned
releases, maintenance releases for old versions, and without the requirement to
deploy to production all the time.
## Terminology
Terminology
-----------
- **Master Branch** - Must always have passing tests, is considered bleeding
edge, and must be named `master`.
@@ -38,159 +38,161 @@ deploy to production all the time.
- **Release Branches** - Used both for short-term preparations of a release, and
also for long-term maintenance of older version.
## Git Common-Flow Specification (Common-Flow)
Git Common-Flow Specification (Common-Flow)
-------------------------------------------
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
1. The Master Branch
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST be considered bleeding edge.
3. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST be considered bleeding edge.
3. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
2. Change Branches
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches". All change
branches MUST have descriptive names. It is RECOMMENDED that you commit
often locally, and you SHOULD regularly push your work to the same named
branch on the remote server.
2. You MUST create separate change branches for each distinctly different
change. You MUST NOT include multiple unrelated changes into a single
change branch.
3. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
4. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
5. After rebasing a change branch on top of its source branch you MUST push
the change branch to the remote server. This will require you to do a
force push, and you SHOULD use the "--force-with-lease" git push option.
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches". All change
branches MUST have descriptive names. It is RECOMMENDED that you commit
often locally, and you SHOULD regularly push your work to the same named
branch on the remote server.
2. You MUST create separate change branches for each distinctly different
change. You MUST NOT include multiple unrelated changes into a single
change branch.
3. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
4. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
5. After rebasing a change branch on top of its source branch you MUST push
the change branch to the remote server. This will require you to do a
force push, and you SHOULD use the "--force-with-lease" git push option.
3. Pull Requests
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent) so others can review and approve your changes.
2. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
3. To get feedback, help, or generally just discuss a change branch with
others, the RECOMMENDED way to do so is by creating a pull request and
discuss the changes with others there.
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent) so others can review and approve your changes.
2. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
3. To get feedback, help, or generally just discuss a change branch with
others, the RECOMMENDED way to do so is by creating a pull request and
discuss the changes with others there.
4. Versioning
1. The project MUST have its version hard-coded somewhere in the
code-base. It is RECOMMENDED that this is done in a file called "VERSION"
located in the root of the project.
2. If you are using a "VERSION" file in the root of the project, this MUST
only contain the exact version string.
3. The version string SHOULD follow the Semantic Versioning
(<http://semver.org/>) format. Use of Semantic Versioning is OPTIONAL,
but the version string MUST NOT have a "v" prefix. For example "v2.11.4"
is bad, and "2.11.4" is good.
1. The project MUST have its version hard-coded somewhere in the
code-base. It is RECOMMENDED that this is done in a file called "VERSION"
located in the root of the project.
2. If you are using a "VERSION" file in the root of the project, this MUST
only contain the exact version string.
3. The version string SHOULD follow the Semantic Versioning
(<http://semver.org/>) format. Use of Semantic Versioning is OPTIONAL,
but the version string MUST NOT have a "v" prefix. For example "v2.11.4"
is bad, and "2.11.4" is good.
5. Releases
1. To create a new release, you MUST create a "version bump" commit which
changes the hard-coded version string of the project. The version bump
commit MUST have a git tag created on it and named as the exact version
string.
2. If you are not using a release branch, then the version bump commit MUST
be created directly on the master branch.
3. The version bump commit MUST have a commit message title of "Bump version
to VERSION". For example, if the new version string is "2.11.4", the
first line of the commit message MUST read: "Bump version to 2.11.4"
4. The release tag on the version bump commit MUST be named exactly the same
as the version string. The tag name can OPTIONALLY be prefixed with
"v". For example the tag name can be either "2.11.4" or "v2.11.4". You
MUST not use a mix of "v" prefixed and non-prefixed tags. Pick one form
and stick to it.
5. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
6. If you use annotated release tags, the first line of the annotation MUST
read "Release VERSION". For example for version "2.11.4" the first line
of the tag annotation would read "Release 2.11.4". The second line must
be blank, and the changelog MUST start on the third line.
1. To create a new release, you MUST create a "version bump" commit which
changes the hard-coded version string of the project. The version bump
commit MUST have a git tag created on it and named as the exact version
string.
2. If you are not using a release branch, then the version bump commit MUST
be created directly on the master branch.
3. The version bump commit MUST have a commit message title of "Bump version
to VERSION". For example, if the new version string is "2.11.4", the
first line of the commit message MUST read: "Bump version to 2.11.4"
4. The release tag on the version bump commit MUST be named exactly the same
as the version string. The tag name can OPTIONALLY be prefixed with
"v". For example the tag name can be either "2.11.4" or "v2.11.4". You
MUST not use a mix of "v" prefixed and non-prefixed tags. Pick one form
and stick to it.
5. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
6. If you use annotated release tags, the first line of the annotation MUST
read "Release VERSION". For example for version "2.11.4" the first line
of the tag annotation would read "Release 2.11.4". The second line must
be blank, and the changelog MUST start on the third line.
6. Release Branches
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Use of release branches is OPTIONAL.
3. Changes in a release branch SHOULD typically come from work being
done against the master branch. Meaning changes SHOULD only trickle
downwards from the master branch. If a change needs to trickle back up
into the master branch, that work should have happened against the master
branch in the first place. One exception to this is version bump commits.
4. There are two types of release branches; short-term, and long-term.
5. Short-Term Release Branches
1. Used for creating a specific versioned release.
2. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
3. MUST have a name of "release-VERSION". For example for version
"2.11.4" the release branch name MUST be "release-2.11.4".
4. When using a short-term release branch, the version bump commit and
release tag MUST be made directly on the release branch itself.
5. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master
branch, and SHOULD be pulled into the release branch by rebasing it
on top of the master branch the same way a change branch pulls in
updates from its source branch.
6. After the version bump commit and release tag have been created, the
release branch MUST be merged back into its source branch and then
deleted. Typically the source branch will be the master branch.
6. Long-Term Release Branches
1. Used for work on versions which are not currently part of the master
branch. Typically this is useful when you need to create a new
maintenance release for a older version.
2. The branch name MUST have a non-specific version number. For example
a long-term release branch for creating new 2.9.x releases would be
named "release-2.9".
3. To create a new release from a long-term release branch, you MUST
create a version bump commit and release tag directly on the release
branch.
4. A long-term release branch MUST be created from the relevant release
tag. For example if the master branch is on version 2.11.4 and there
is a security fix for all 2.9.x releases, the latest of which is
"2.9.7". Create a new branch called "release-2.9" off of the "2.9.7"
release tag. The security fix release will then end up being version
"2.9.8".
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Use of release branches is OPTIONAL.
3. Changes in a release branch SHOULD typically come from work being
done against the master branch. Meaning changes SHOULD only trickle
downwards from the master branch. If a change needs to trickle back up
into the master branch, that work should have happened against the master
branch in the first place. One exception to this is version bump commits.
4. There are two types of release branches; short-term, and long-term.
5. Short-Term Release Branches
1. Used for creating a specific versioned release.
2. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
3. MUST have a name of "release-VERSION". For example for version
"2.11.4" the release branch name MUST be "release-2.11.4".
4. When using a short-term release branch, the version bump commit and
release tag MUST be made directly on the release branch itself.
5. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master
branch, and SHOULD be pulled into the release branch by rebasing it
on top of the master branch the same way a change branch pulls in
updates from its source branch.
6. After the version bump commit and release tag have been created, the
release branch MUST be merged back into its source branch and then
deleted. Typically the source branch will be the master branch.
6. Long-Term Release Branches
1. Used for work on versions which are not currently part of the master
branch. Typically this is useful when you need to create a new
maintenance release for a older version.
2. The branch name MUST have a non-specific version number. For example
a long-term release branch for creating new 2.9.x releases would be
named "release-2.9".
3. To create a new release from a long-term release branch, you MUST
create a version bump commit and release tag directly on the release
branch.
4. A long-term release branch MUST be created from the relevant release
tag. For example if the master branch is on version 2.11.4 and there
is a security fix for all 2.9.x releases, the latest of which is
"2.9.7". Create a new branch called "release-2.9" off of the "2.9.7"
release tag. The security fix release will then end up being version
"2.9.8".
7. Bug Fixes & Rollback
1. You MUST NOT under any circumstances force push to the master branch.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
1. You MUST NOT under any circumstances force push to the master branch.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
8. Git Best Practices
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
documentation:
<https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project>
2. You SHOULD never blindly commit all changes with "git commit -a". It is
RECOMMENDED you use "git add -i" to add individual changes to the staging
area so you are fully aware of what you are committing.
3. You SHOULD always use "--force-with-lease" when doing a force push. The
regular "--force" option is dangerous and destructive. More
information:
<https://developer.atlassian.com/blog/2015/04/force-with-lease/>
4. You SHOULD understand and be comfortable with
rebasing: <https://git-scm.com/book/en/v2/Git-Branching-Rebasing>
5. It is RECOMMENDED that you always do "git pull --rebase" instead of "git
pull" to avoid unnecessary merge commits. You can make this the default
behavior of "git pull" with "git config --global pull.rebase true".
6. It is RECOMMENDED that all branches be merged using "git merge --no-ff".
This makes sure the reference to the original branch is kept in the
commits, allows one to revert a merge by reverting a single merge commit,
and creates a merge commit to mark the integration of the branch with
master.
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
documentation:
<https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project>
2. You SHOULD never blindly commit all changes with "git commit -a". It is
RECOMMENDED you use "git add -i" to add individual changes to the staging
area so you are fully aware of what you are committing.
3. You SHOULD always use "--force-with-lease" when doing a force push. The
regular "--force" option is dangerous and destructive. More
information:
<https://developer.atlassian.com/blog/2015/04/force-with-lease/>
4. You SHOULD understand and be comfortable with
rebasing: <https://git-scm.com/book/en/v2/Git-Branching-Rebasing>
5. It is RECOMMENDED that you always do "git pull --rebase" instead of "git
pull" to avoid unnecessary merge commits. You can make this the default
behavior of "git pull" with "git config --global pull.rebase true".
6. It is RECOMMENDED that all branches be merged using "git merge --no-ff".
This makes sure the reference to the original branch is kept in the
commits, allows one to revert a merge by reverting a single merge commit,
and creates a merge commit to mark the integration of the branch with
master.
## About
About
-----
The Git Common-Flow specification is authored
by [Jim Myhrberg](http://jimeh.me).
@@ -198,6 +200,7 @@ by [Jim Myhrberg](http://jimeh.me).
If you'd like to leave feedback,
please [open an issue on GitHub](https://github.com/jimeh/common-flow/issues).
## License
License
-------
[Creative Commons - CC BY 3.0](http://creativecommons.org/licenses/by/3.0/)

View File

@@ -2,12 +2,11 @@
title: Git Common-Flow 1.0.0-rc.3
version: 1.0.0-rc.3
---
Git Common-Flow 1.0.0-rc.3
===========================
# Git Common-Flow 1.0.0-rc.3
<img src="/spec/1.0.0-rc.3.svg" alt="Git Common-Flow 1.0.0-rc.3 diagram" width="100%" />
## Summary
Summary
-------
Common-Flow is an attempt to gather a sensible selection of the most common
usage patterns of git into a single and concise specification. It is based on
@@ -19,7 +18,8 @@ In short, Common-Flow is essentially GitHub Flow with the addition of versioned
releases, optional release branches, and without the requirement to deploy to
production all the time.
## Terminology
Terminology
-----------
- **Master Branch** - Must be named "master", must always have passing tests,
and is not guaranteed to always work in production environments.
@@ -39,164 +39,166 @@ production all the time.
- **Release Branches** - Used both for short-term preparations of a release, and
also for long-term maintenance of older version.
## Git Common-Flow Specification (Common-Flow)
Git Common-Flow Specification (Common-Flow)
-------------------------------------------
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
1. TL;DR
1. Don't break the master branch.
2. A release is a git tag.
1. Don't break the master branch.
2. A release is a git tag.
2. The Master Branch
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST always be in a non-broken state with its test
suite passing.
3. The master branch IS NOT guaranteed to always work in production
environments. Despite test suites passing it may at times contain
unfinished work. Only releases may be considered safe for production use.
4. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch IS NOT guaranteed to always work in production
environments. Despite test suites passing it may at times contain
unfinished work. Only releases may be considered safe for production use.
5. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
3. Change Branches
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches". All change
branches MUST have descriptive names. It is RECOMMENDED that you commit
often locally, and you SHOULD regularly push your work to the same named
branch on the remote server.
2. You MUST create separate change branches for each distinctly different
change. You MUST NOT include multiple unrelated changes into a single
change branch.
3. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
4. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
5. After rebasing a change branch on top of its source branch you MUST push
the change branch to the remote server. This will require you to do a
force push, and you SHOULD use the "--force-with-lease" git push option.
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches". All change
branches MUST have descriptive names. It is RECOMMENDED that you commit
often locally, and you SHOULD regularly push your work to the same named
branch on the remote server.
2. You MUST create separate change branches for each distinctly different
change. You MUST NOT include multiple unrelated changes into a single
change branch.
3. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
4. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
5. After rebasing a change branch on top of its source branch you MUST push
the change branch to the remote server. This will require you to do a
force push, and you SHOULD use the "--force-with-lease" git push option.
4. Pull Requests
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent) so others can review and approve your changes.
2. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
3. To get feedback, help, or generally just discuss a change branch with
others, the RECOMMENDED way to do so is by creating a pull request and
discuss the changes with others there.
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent) so others can review and approve your changes.
2. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
3. To get feedback, help, or generally just discuss a change branch with
others, the RECOMMENDED way to do so is by creating a pull request and
discuss the changes with others there.
5. Versioning
1. The project MUST have its version hard-coded somewhere in the
code-base. It is RECOMMENDED that this is done in a file called "VERSION"
located in the root of the project.
2. If you are using a "VERSION" file in the root of the project, this MUST
only contain the exact version string.
3. The version string SHOULD follow the Semantic Versioning
(<http://semver.org/>) format. Use of Semantic Versioning is OPTIONAL,
but the version string MUST NOT have a "v" prefix. For example "v2.11.4"
is bad, and "2.11.4" is good.
1. The project MUST have its version hard-coded somewhere in the
code-base. It is RECOMMENDED that this is done in a file called "VERSION"
located in the root of the project.
2. If you are using a "VERSION" file in the root of the project, this MUST
only contain the exact version string.
3. The version string SHOULD follow the Semantic Versioning
(<http://semver.org/>) format. Use of Semantic Versioning is OPTIONAL,
but the version string MUST NOT have a "v" prefix. For example "v2.11.4"
is bad, and "2.11.4" is good.
6. Releases
1. To create a new release, you MUST create a "version bump" commit which
changes the hard-coded version string of the project. The version bump
commit MUST have a git tag created on it and named as the exact version
string.
2. If you are not using a release branch, then the version bump commit MUST
be created directly on the master branch.
3. The version bump commit MUST have a commit message title of "Bump version
to VERSION". For example, if the new version string is "2.11.4", the
first line of the commit message MUST read: "Bump version to 2.11.4"
4. The release tag on the version bump commit MUST be named exactly the same
as the version string. The tag name can OPTIONALLY be prefixed with
"v". For example the tag name can be either "2.11.4" or "v2.11.4". You
MUST not use a mix of "v" prefixed and non-prefixed tags. Pick one form
and stick to it.
5. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
6. If you use annotated release tags, the first line of the annotation MUST
read "Release VERSION". For example for version "2.11.4" the first line
of the tag annotation would read "Release 2.11.4". The second line must
be blank, and the changelog MUST start on the third line.
1. To create a new release, you MUST create a "version bump" commit which
changes the hard-coded version string of the project. The version bump
commit MUST have a git tag created on it and named as the exact version
string.
2. If you are not using a release branch, then the version bump commit MUST
be created directly on the master branch.
3. The version bump commit MUST have a commit message title of "Bump version
to VERSION". For example, if the new version string is "2.11.4", the
first line of the commit message MUST read: "Bump version to 2.11.4"
4. The release tag on the version bump commit MUST be named exactly the same
as the version string. The tag name can OPTIONALLY be prefixed with
"v". For example the tag name can be either "2.11.4" or "v2.11.4". You
MUST not use a mix of "v" prefixed and non-prefixed tags. Pick one form
and stick to it.
5. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
6. If you use annotated release tags, the first line of the annotation MUST
read "Release VERSION". For example for version "2.11.4" the first line
of the tag annotation would read "Release 2.11.4". The second line must
be blank, and the changelog MUST start on the third line.
7. Release Branches
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Use of release branches is OPTIONAL.
3. Changes in a release branch SHOULD typically come from work being
done against the master branch. Meaning changes SHOULD only trickle
downwards from the master branch. If a change needs to trickle back up
into the master branch, that work should have happened against the master
branch in the first place. One exception to this is version bump commits.
4. There are two types of release branches; short-term, and long-term.
5. Short-Term Release Branches
1. Used for creating a specific versioned release.
2. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
3. MUST have a name of "release-VERSION". For example for version
"2.11.4" the release branch name MUST be "release-2.11.4".
4. When using a short-term release branch, the version bump commit and
release tag MUST be made directly on the release branch itself.
5. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master
branch, and SHOULD be pulled into the release branch by rebasing it
on top of the master branch the same way a change branch pulls in
updates from its source branch.
6. After the version bump commit and release tag have been created, the
release branch MUST be merged back into its source branch and then
deleted. Typically the source branch will be the master branch.
6. Long-Term Release Branches
1. Used for work on versions which are not currently part of the master
branch. Typically this is useful when you need to create a new
maintenance release for a older version.
2. The branch name MUST have a non-specific version number. For example
a long-term release branch for creating new 2.9.x releases would be
named "release-2.9".
3. To create a new release from a long-term release branch, you MUST
create a version bump commit and release tag directly on the release
branch.
4. A long-term release branch MUST be created from the relevant release
tag. For example if the master branch is on version 2.11.4 and there
is a security fix for all 2.9.x releases, the latest of which is
"2.9.7". Create a new branch called "release-2.9" off of the "2.9.7"
release tag. The security fix release will then end up being version
"2.9.8".
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Use of release branches is OPTIONAL.
3. Changes in a release branch SHOULD typically come from work being
done against the master branch. Meaning changes SHOULD only trickle
downwards from the master branch. If a change needs to trickle back up
into the master branch, that work should have happened against the master
branch in the first place. One exception to this is version bump commits.
4. There are two types of release branches; short-term, and long-term.
5. Short-Term Release Branches
1. Used for creating a specific versioned release.
2. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
3. MUST have a name of "release-VERSION". For example for version
"2.11.4" the release branch name MUST be "release-2.11.4".
4. When using a short-term release branch, the version bump commit and
release tag MUST be made directly on the release branch itself.
5. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master
branch, and SHOULD be pulled into the release branch by rebasing it
on top of the master branch the same way a change branch pulls in
updates from its source branch.
6. After the version bump commit and release tag have been created, the
release branch MUST be merged back into its source branch and then
deleted. Typically the source branch will be the master branch.
6. Long-Term Release Branches
1. Used for work on versions which are not currently part of the master
branch. Typically this is useful when you need to create a new
maintenance release for a older version.
2. The branch name MUST have a non-specific version number. For example
a long-term release branch for creating new 2.9.x releases would be
named "release-2.9".
3. To create a new release from a long-term release branch, you MUST
create a version bump commit and release tag directly on the release
branch.
4. A long-term release branch MUST be created from the relevant release
tag. For example if the master branch is on version 2.11.4 and there
is a security fix for all 2.9.x releases, the latest of which is
"2.9.7". Create a new branch called "release-2.9" off of the "2.9.7"
release tag. The security fix release will then end up being version
"2.9.8".
8. Bug Fixes & Rollback
1. You MUST NOT under any circumstances force push to the master branch.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
1. You MUST NOT under any circumstances force push to the master branch.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
9. Git Best Practices
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
documentation:
<https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines>
2. You SHOULD never blindly commit all changes with "git commit -a". It is
RECOMMENDED you use "git add -i" to add individual changes to the staging
area so you are fully aware of what you are committing.
3. You SHOULD always use "--force-with-lease" when doing a force push. The
regular "--force" option is dangerous and destructive. More
information:
<https://developer.atlassian.com/blog/2015/04/force-with-lease/>
4. You SHOULD understand and be comfortable with
rebasing: <https://git-scm.com/book/en/v2/Git-Branching-Rebasing>
5. It is RECOMMENDED that you always do "git pull --rebase" instead of "git
pull" to avoid unnecessary merge commits. You can make this the default
behavior of "git pull" with "git config --global pull.rebase true".
6. It is RECOMMENDED that all branches be merged using "git merge --no-ff".
This makes sure the reference to the original branch is kept in the
commits, allows one to revert a merge by reverting a single merge commit,
and creates a merge commit to mark the integration of the branch with
master.
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
documentation:
<https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_commit_guidelines>
2. You SHOULD never blindly commit all changes with "git commit -a". It is
RECOMMENDED you use "git add -i" to add individual changes to the staging
area so you are fully aware of what you are committing.
3. You SHOULD always use "--force-with-lease" when doing a force push. The
regular "--force" option is dangerous and destructive. More
information:
<https://developer.atlassian.com/blog/2015/04/force-with-lease/>
4. You SHOULD understand and be comfortable with
rebasing: <https://git-scm.com/book/en/v2/Git-Branching-Rebasing>
5. It is RECOMMENDED that you always do "git pull --rebase" instead of "git
pull" to avoid unnecessary merge commits. You can make this the default
behavior of "git pull" with "git config --global pull.rebase true".
6. It is RECOMMENDED that all branches be merged using "git merge --no-ff".
This makes sure the reference to the original branch is kept in the
commits, allows one to revert a merge by reverting a single merge commit,
and creates a merge commit to mark the integration of the branch with
master.
## About
About
-----
The Git Common-Flow specification is authored
by [Jim Myhrberg](http://jimeh.me).
@@ -204,6 +206,7 @@ by [Jim Myhrberg](http://jimeh.me).
If you'd like to leave feedback,
please [open an issue on GitHub](https://github.com/jimeh/common-flow/issues).
## License
License
-------
[Creative Commons - CC BY 3.0](http://creativecommons.org/licenses/by/3.0/)

View File

@@ -2,12 +2,11 @@
title: Git Common-Flow 1.0.0-rc.4
version: 1.0.0-rc.4
---
Git Common-Flow 1.0.0-rc.4
===========================
# Git Common-Flow 1.0.0-rc.4
<img src="/spec/1.0.0-rc.4.svg" alt="Git Common-Flow 1.0.0-rc.4 diagram" width="100%" />
## Summary
Summary
-------
Common-Flow is an attempt to gather a sensible selection of the most common
usage patterns of git into a single and concise specification. It is based on
@@ -19,7 +18,8 @@ In short, Common-Flow is essentially GitHub Flow with the addition of versioned
releases, optional release branches, and without the requirement to deploy to
production all the time.
## Terminology
Terminology
-----------
- **Master Branch** - Must be named "master", must always have passing tests,
and is not guaranteed to always work in production environments.
@@ -38,182 +38,183 @@ production all the time.
- **Release Branches** - Used both for short-term preparations of a release, and
also for long-term maintenance of older version.
## Git Common-Flow Specification (Common-Flow)
Git Common-Flow Specification (Common-Flow)
-------------------------------------------
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
1. TL;DR
1. Don't break the master branch.
2. A release is a git tag.
1. Don't break the master branch.
2. A release is a git tag.
2. The Master Branch
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST always be in a non-broken state with its test
suite passing.
3. The master branch IS NOT guaranteed to always work in production
environments. Despite test suites passing it may at times contain
unfinished work. Only releases may be considered safe for production use.
4. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch IS NOT guaranteed to always work in production
environments. Despite test suites passing it may at times contain
unfinished work. Only releases may be considered safe for production use.
5. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
3. Change Branches
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches".
2. All change branches MUST have descriptive names.
3. It is RECOMMENDED that you commit often locally, and that you try and
keep the commits reasonably structured to avoid a messy and confusing git
history.
4. You SHOULD regularly push your work to the same named branch on the
remote server.
5. You SHOULD create separate change branches for each distinctly different
change. You SHOULD NOT include multiple unrelated changes into a single
change branch.
6. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
7. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
8. After updating a change branch from its source branch you MUST push the
change branch to the remote server. Due to the nature of rebasing, you
will be required to do a force push, and you MUST use the
"--force-with-lease" git push option when doing so instead of the regular
"--force".
9. If there is a truly valid technical reason to not use rebase when
updating change branches, then you can update change branches via merge
instead of rebase. The decision to use merge MUST only be taken after all
possible options to use rebase have been tried and failed. People not
understanding how to use rebase is NOT a valid reason to use merge. If
you do decide to use merge instead of rebase, you MUST NOT use a mixture
of both methods, pick one and stick to it.
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches".
2. All change branches MUST have descriptive names.
3. It is RECOMMENDED that you commit often locally, and that you try and
keep the commits reasonably structured to avoid a messy and confusing git
history.
4. You SHOULD regularly push your work to the same named branch on the
remote server.
5. You SHOULD create separate change branches for each distinctly different
change. You SHOULD NOT include multiple unrelated changes into a single
change branch.
6. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
7. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
8. After updating a change branch from its source branch you MUST push the
change branch to the remote server. Due to the nature of rebasing, you
will be required to do a force push, and you MUST use the
"--force-with-lease" git push option when doing so instead of the regular
"--force".
9. If there is a truly valid technical reason to not use rebase when
updating change branches, then you can update change branches via merge
instead of rebase. The decision to use merge MUST only be taken after all
possible options to use rebase have been tried and failed. People not
understanding how to use rebase is NOT a valid reason to use merge. If
you do decide to use merge instead of rebase, you MUST NOT use a mixture
of both methods, pick one and stick to it.
4. Pull Requests
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent).
2. The purpose of a pull request is to allow others to review your changes
and give feedback. You can then fix any issues, complaints, and more that
might arise, and then let people review again.
3. Before creating a pull request, it is RECOMMENDED that you consider the
state of your change branch's commit history. If it is messy and
confusing, it might be a good idea to rebase your branch with "git rebase
-i" to present a cleaner and easier to follow commit history for your
reviewers.
4. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
5. To get feedback, help, or generally just discuss a change branch with
others, the RECOMMENDED way to do so is by creating a pull request and
discuss the changes with others there.
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent).
2. The purpose of a pull request is to allow others to review your changes
and give feedback. You can then fix any issues, complaints, and more that
might arise, and then let people review again.
3. Before creating a pull request, it is RECOMMENDED that you consider the
state of your change branch's commit history. If it is messy and
confusing, it might be a good idea to rebase your branch with "git rebase
-i" to present a cleaner and easier to follow commit history for your
reviewers.
4. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
5. To get feedback, help, or generally just discuss a change branch with
others, the RECOMMENDED way to do so is by creating a pull request and
discuss the changes with others there.
5. Versioning
1. A "version string" is a typically mostly numeric string that identifies a
specific version of a project. The version string itself MUST NOT have a
"v" prefix, but the version string can be displayed with a "v" prefix to
indicate it is a version that is being referred to.
2. The source of truth for a project's version MUST be a git tag with a name
based on the version string. This kind of tag MUST be referred to as a
"release tag".
3. It is OPTIONAL, but RECOMMENDED to also keep the version string
hard-coded somewhere in the project code-base.
4. If you hard-code the version string into the code-base, it is RECOMMENDED
that you do so in a file called "VERSION" located in the root of the
project. But be mindful of the conventions of your programming language
and community when choosing if, where and how to hard-code the version
string.
5. If you are using a "VERSION" file in the root of the project, this file
MUST only contain the exact version string, meaning it MUST NOT have a
"v" prefix. For example "v2.11.4" is bad, and "2.11.4" is good.
6. It is OPTIONAL, but RECOMMENDED that that the version string follows
Semantic Versioning (<http://semver.org/>).
1. A "version string" is a typically mostly numeric string that identifies a
specific version of a project. The version string itself MUST NOT have a
"v" prefix, but the version string can be displayed with a "v" prefix to
indicate it is a version that is being referred to.
2. The source of truth for a project's version MUST be a git tag with a name
based on the version string. This kind of tag MUST be referred to as a
"release tag".
3. It is OPTIONAL, but RECOMMENDED to also keep the version string
hard-coded somewhere in the project code-base.
4. If you hard-code the version string into the code-base, it is RECOMMENDED
that you do so in a file called "VERSION" located in the root of the
project. But be mindful of the conventions of your programming language
and community when choosing if, where and how to hard-code the version
string.
5. If you are using a "VERSION" file in the root of the project, this file
MUST only contain the exact version string, meaning it MUST NOT have a
"v" prefix. For example "v2.11.4" is bad, and "2.11.4" is good.
6. It is OPTIONAL, but RECOMMENDED that that the version string follows
Semantic Versioning (<http://semver.org/>).
6. Releases
1. To create a new release, you MUST create a git tag named as the exact
version string of the release. This kind of tag MUST be referred to as a
"release tag".
2. The release tag name can OPTIONALLY be prefixed with "v". For example the
tag name can be either "2.11.4" or "v2.11.4". It is however RECOMMENDED
that you do not use a "v" prefix. You MUST NOT use a mixture of "v"
prefixed and non-prefixed tags. Pick one form and stick to it.
3. If the version string is hard-coded into the code-base, you MUST create a
"version bump" commit which changes the hard-coded version string of the
project.
4. When using version bump commits, the release tag MUST be placed on the
version bump commit.
5. If you are not using a release branch, then the release tag, and if
relevant the version bump commit, MUST be created directly on the master
branch.
6. The version bump commit SHOULD have a commit message title of "Bump
version to VERSION". For example, if the new version string is "2.11.4",
the first line of the commit message SHOULD read: "Bump version to
2.11.4"
7. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
8. If you use annotated release tags, the first line of the annotation
SHOULD read "Release VERSION". For example for version "2.11.4" the first
line of the tag annotation SHOULD read "Release 2.11.4". The second line
MUST be blank, and the changelog MUST start on the third line.
1. To create a new release, you MUST create a git tag named as the exact
version string of the release. This kind of tag MUST be referred to as a
"release tag".
2. The release tag name can OPTIONALLY be prefixed with "v". For example the
tag name can be either "2.11.4" or "v2.11.4". It is however RECOMMENDED
that you do not use a "v" prefix. You MUST NOT use a mixture of "v"
prefixed and non-prefixed tags. Pick one form and stick to it.
3. If the version string is hard-coded into the code-base, you MUST create a
"version bump" commit which changes the hard-coded version string of the
project.
4. When using version bump commits, the release tag MUST be placed on the
version bump commit.
5. If you are not using a release branch, then the release tag, and if
relevant the version bump commit, MUST be created directly on the master
branch.
6. The version bump commit SHOULD have a commit message title of "Bump
version to VERSION". For example, if the new version string is "2.11.4",
the first line of the commit message SHOULD read: "Bump version to
2.11.4"
7. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
8. If you use annotated release tags, the first line of the annotation
SHOULD read "Release VERSION". For example for version "2.11.4" the first
line of the tag annotation SHOULD read "Release 2.11.4". The second line
MUST be blank, and the changelog MUST start on the third line.
7. Short-Term Release Branches
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Any release branch which has a name ending with a specific version
string, MUST be referred to as a "short-term release branch".
3. Use of short-term release branches are OPTIONAL, and intended to be used
to create a specific versioned release.
4. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
5. Short-term release branches MUST have a name of "release-VERSION". For
example for version "2.11.4" the release branch name MUST be
"release-2.11.4".
6. When using a short-term release branch to create a release, the release
tag and if used, version bump commit, MUST be placed directly on the
short-term release branch itself.
7. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master branch,
and SHOULD be pulled into the release branch by rebasing it on top of the
master branch the same way a change branch pulls in updates from its
source branch.
8. After a release tag has been created, the release branch MUST be merged
back into its source branch and then deleted. Typically the source branch
will be the master branch.
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Any release branch which has a name ending with a specific version
string, MUST be referred to as a "short-term release branch".
3. Use of short-term release branches are OPTIONAL, and intended to be used
to create a specific versioned release.
4. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
5. Short-term release branches MUST have a name of "release-VERSION". For
example for version "2.11.4" the release branch name MUST be
"release-2.11.4".
6. When using a short-term release branch to create a release, the release
tag and if used, version bump commit, MUST be placed directly on the
short-term release branch itself.
7. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master branch,
and SHOULD be pulled into the release branch by rebasing it on top of the
master branch the same way a change branch pulls in updates from its
source branch.
8. After a release tag has been created, the release branch MUST be merged
back into its source branch and then deleted. Typically the source branch
will be the master branch.
8. Long-term Release Branches
1. Any release branch which has a name ending with a non-specific version
string, MUST be referred to as a "long-term release branch". For example
"release-2.11" is a long-term release branch, while "release-2.11.4" is a
short-term release branch.
2. Use of long-term release branches are OPTIONAL, and intended for work on
versions which are not currently part of the master branch. Typically
this is useful when you need to create a new maintenance release for a
older version.
3. A long-term release branch MUST have a name with a non-specific version
number. For example a long-term release branch for creating new 2.9.x
releases MUST be named "release-2.9".
4. Long-term release branches for maintenance releases of older versions
MUST be created from the relevant release tag. For example if the master
branch is on version 2.11.4 and there is a security fix for all 2.9.x
releases, the latest of which is "2.9.7". Create a new branch called
"release-2.9" off of the "2.9.7" release tag. The security fix release
will then end up being version "2.9.8".
5. To create a new release from a long-term release branch, you MUST follow
the same process as a release from the master branch, except the
long-term release branch takes the place of the master branch.
6. A long-term release branch should be treated with the same respect as the
master branch. It is effectively the master branch for the release series
in question. Meaning it MUST always be in a non-broken state, MUST NOT be
force pushed to, etc.
1. Any release branch which has a name ending with a non-specific version
string, MUST be referred to as a "long-term release branch". For example
"release-2.11" is a long-term release branch, while "release-2.11.4" is a
short-term release branch.
2. Use of long-term release branches are OPTIONAL, and intended for work on
versions which are not currently part of the master branch. Typically
this is useful when you need to create a new maintenance release for a
older version.
3. A long-term release branch MUST have a name with a non-specific version
number. For example a long-term release branch for creating new 2.9.x
releases MUST be named "release-2.9".
4. Long-term release branches for maintenance releases of older versions
MUST be created from the relevant release tag. For example if the master
branch is on version 2.11.4 and there is a security fix for all 2.9.x
releases, the latest of which is "2.9.7". Create a new branch called
"release-2.9" off of the "2.9.7" release tag. The security fix release
will then end up being version "2.9.8".
5. To create a new release from a long-term release branch, you MUST follow
the same process as a release from the master branch, except the
long-term release branch takes the place of the master branch.
7. A long-term release branch should be treated with the same respect as the
master branch. It is effectively the master branch for the release series
in question. Meaning it MUST always be in a non-broken state, MUST NOT be
force pushed to, etc.
9. Bug Fixes & Rollback
1. You MUST NOT under any circumstances force push to the master branch or
to long-term release branches.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
1. You MUST NOT under any circumstances force push to the master branch or
to long-term release branches.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
10. Git Best Practices
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
@@ -238,7 +239,8 @@ interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
and creates a merge commit to mark the integration of the branch with
master.
## FAQ
FAQ
---
### Why use Common-Flow instead of Git Flow, and how does it differ?
@@ -321,7 +323,8 @@ complicated task and you're short on time, a short-term release branch gives you
a instant fix to the situation at hand, and let's you resolve the issues with
the master branch when you have more time on your hands.
## About
About
-----
The Git Common-Flow specification is authored
by [Jim Myhrberg](http://jimeh.me).
@@ -329,6 +332,7 @@ by [Jim Myhrberg](http://jimeh.me).
If you'd like to leave feedback,
please [open an issue on GitHub](https://github.com/jimeh/common-flow/issues).
## License
License
-------
[Creative Commons - CC BY 3.0](http://creativecommons.org/licenses/by/3.0/)

View File

@@ -2,12 +2,11 @@
title: Git Common-Flow 1.0.0-rc.5
version: 1.0.0-rc.5
---
Git Common-Flow 1.0.0-rc.5
===========================
# Git Common-Flow 1.0.0-rc.5
<img src="/spec/1.0.0-rc.5.svg" alt="Git Common-Flow 1.0.0-rc.5 diagram" width="100%" />
## Introduction
Introduction
------------
Common-Flow is an attempt to gather a sensible selection of the most common
usage patterns of git into a single and concise specification. It is based on
@@ -19,7 +18,8 @@ In short, Common-Flow is essentially GitHub Flow with the addition of versioned
releases, optional release branches, and without the requirement to deploy to
production all the time.
## Summary
Summary
-------
- The "master" branch is the mainline branch with latest changes, and must not
be broken.
@@ -32,7 +32,8 @@ production all the time.
- Release branches can be used to avoid change freezes on master. They are not
required, instead they are available if you need them.
## Terminology
Terminology
-----------
- **Master Branch** - Must be named "master", must always have passing tests,
and is not guaranteed to always work in production environments.
@@ -51,183 +52,184 @@ production all the time.
- **Release Branches** - Used both for short-term preparations of a release, and
also for long-term maintenance of older version.
## Git Common-Flow Specification (Common-Flow)
Git Common-Flow Specification (Common-Flow)
-------------------------------------------
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD",
"SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be
interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
1. TL;DR
1. Do not break the master branch.
2. A release is a git tag.
1. Do not break the master branch.
2. A release is a git tag.
2. The Master Branch
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST always be in a non-broken state with its test
suite passing.
3. The master branch IS NOT guaranteed to always work in production
environments. Despite test suites passing it may at times contain
unfinished work. Only releases may be considered safe for production use.
4. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
1. A branch named "master" MUST exist and it MUST be referred to as the
"master branch".
2. The master branch MUST always be in a non-broken state with its test
suite passing.
4. The master branch IS NOT guaranteed to always work in production
environments. Despite test suites passing it may at times contain
unfinished work. Only releases may be considered safe for production use.
5. The master branch SHOULD always be in a "as near as possibly ready for
release/production" state to reduce any friction with creating a new
release.
3. Change Branches
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches".
2. All change branches MUST have descriptive names.
3. It is RECOMMENDED that you commit often locally, and that you try and
keep the commits reasonably structured to avoid a messy and confusing git
history.
4. You SHOULD regularly push your work to the same named branch on the
remote server.
5. You SHOULD create separate change branches for each distinctly different
change. You SHOULD NOT include multiple unrelated changes into a single
change branch.
6. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
7. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
8. After updating a change branch from its source branch you MUST push the
change branch to the remote server. Due to the nature of rebasing, you
will be required to do a force push, and you MUST use the
"--force-with-lease" git push option when doing so instead of the regular
"--force".
9. If there is a truly valid technical reason to not use rebase when
updating change branches, then you can update change branches via merge
instead of rebase. The decision to use merge MUST only be taken after all
possible options to use rebase have been tried and failed. People not
understanding how to use rebase is NOT a valid reason to use merge. If
you do decide to use merge instead of rebase, you MUST NOT use a mixture
of both methods, pick one and stick to it.
1. Each change (feature, bugfix, etc.) MUST be performed on separate
branches that SHOULD be referred to as "change branches".
2. All change branches MUST have descriptive names.
3. It is RECOMMENDED that you commit often locally, and that you try and
keep the commits reasonably structured to avoid a messy and confusing git
history.
4. You SHOULD regularly push your work to the same named branch on the
remote server.
5. You SHOULD create separate change branches for each distinctly different
change. You SHOULD NOT include multiple unrelated changes into a single
change branch.
6. When a change branch is created, the branch that it is created from
SHOULD be referred to as the "source branch". Each change branch also
needs a designated "merge target" branch, typically this will be the same
as the source branch.
7. Change branches MUST be regularly updated with any changes from their
source branch. This MUST be done by rebasing the change branch on top of
the source branch.
8. After updating a change branch from its source branch you MUST push the
change branch to the remote server. Due to the nature of rebasing, you
will be required to do a force push, and you MUST use the
"--force-with-lease" git push option when doing so instead of the regular
"--force".
9. If there is a truly valid technical reason to not use rebase when
updating change branches, then you can update change branches via merge
instead of rebase. The decision to use merge MUST only be taken after all
possible options to use rebase have been tried and failed. People not
understanding how to use rebase is NOT a valid reason to use merge. If
you do decide to use merge instead of rebase, you MUST NOT use a mixture
of both methods, pick one and stick to it.
4. Pull Requests
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent).
2. The purpose of a pull request is to allow others to review your changes
and give feedback. You can then fix any issues, complaints, and more that
might arise, and then let people review again.
3. Before creating a pull request, it is RECOMMENDED that you consider the
state of your change branch's commit history. If it is messy and
confusing, it might be a good idea to rebase your branch with "git rebase
-i" to present a cleaner and easier to follow commit history for your
reviewers.
4. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
5. To get feedback, help, or generally just discuss a change branch with
others, it is RECOMMENDED you create a pull request and discuss the
changes with others there. This leaves a clear and visible history of
how, when, and why the code looks and behaves the way it does.
1. To merge a change branch into its merge target, you MUST open a "pull
request" (or equivalent).
2. The purpose of a pull request is to allow others to review your changes
and give feedback. You can then fix any issues, complaints, and more that
might arise, and then let people review again.
3. Before creating a pull request, it is RECOMMENDED that you consider the
state of your change branch's commit history. If it is messy and
confusing, it might be a good idea to rebase your branch with "git rebase
-i" to present a cleaner and easier to follow commit history for your
reviewers.
4. A pull request MUST only be merged when the change branch is up-to-date
with its source branch, the test suite is passing, and you and others are
happy with the change. This is especially important if the merge target
is the master branch.
5. To get feedback, help, or generally just discuss a change branch with
others, it is RECOMMENDED you create a pull request and discuss the
changes with others there. This leaves a clear and visible history of
how, when, and why the code looks and behaves the way it does.
5. Versioning
1. A "version string" is a typically mostly numeric string that identifies a
specific version of a project. The version string itself MUST NOT have a
"v" prefix, but the version string can be displayed with a "v" prefix to
indicate it is a version that is being referred to.
2. The source of truth for a project's version MUST be a git tag with a name
based on the version string. This kind of tag MUST be referred to as a
"release tag".
3. It is OPTIONAL, but RECOMMENDED to also keep the version string
hard-coded somewhere in the project code-base.
4. If you hard-code the version string into the code-base, it is RECOMMENDED
that you do so in a file called "VERSION" located in the root of the
project. But be mindful of the conventions of your programming language
and community when choosing if, where and how to hard-code the version
string.
5. If you are using a "VERSION" file in the root of the project, this file
MUST only contain the exact version string, meaning it MUST NOT have a
"v" prefix. For example "v2.11.4" is bad, and "2.11.4" is good.
6. It is OPTIONAL, but RECOMMENDED that that the version string follows
Semantic Versioning (<http://semver.org/>).
1. A "version string" is a typically mostly numeric string that identifies a
specific version of a project. The version string itself MUST NOT have a
"v" prefix, but the version string can be displayed with a "v" prefix to
indicate it is a version that is being referred to.
2. The source of truth for a project's version MUST be a git tag with a name
based on the version string. This kind of tag MUST be referred to as a
"release tag".
3. It is OPTIONAL, but RECOMMENDED to also keep the version string
hard-coded somewhere in the project code-base.
4. If you hard-code the version string into the code-base, it is RECOMMENDED
that you do so in a file called "VERSION" located in the root of the
project. But be mindful of the conventions of your programming language
and community when choosing if, where and how to hard-code the version
string.
5. If you are using a "VERSION" file in the root of the project, this file
MUST only contain the exact version string, meaning it MUST NOT have a
"v" prefix. For example "v2.11.4" is bad, and "2.11.4" is good.
6. It is OPTIONAL, but RECOMMENDED that that the version string follows
Semantic Versioning (<http://semver.org/>).
6. Releases
1. To create a new release, you MUST create a git tag named as the exact
version string of the release. This kind of tag MUST be referred to as a
"release tag".
2. The release tag name can OPTIONALLY be prefixed with "v". For example the
tag name can be either "2.11.4" or "v2.11.4". It is however RECOMMENDED
that you do not use a "v" prefix. You MUST NOT use a mixture of "v"
prefixed and non-prefixed tags. Pick one form and stick to it.
3. If the version string is hard-coded into the code-base, you MUST create a
"version bump" commit which changes the hard-coded version string of the
project.
4. When using version bump commits, the release tag MUST be placed on the
version bump commit.
5. If you are not using a release branch, then the release tag, and if
relevant the version bump commit, MUST be created directly on the master
branch.
6. The version bump commit SHOULD have a commit message title of "Bump
version to VERSION". For example, if the new version string is "2.11.4",
the first line of the commit message SHOULD read: "Bump version to
2.11.4"
7. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
8. If you use annotated release tags, the first line of the annotation
SHOULD read "Release VERSION". For example for version "2.11.4" the first
line of the tag annotation SHOULD read "Release 2.11.4". The second line
MUST be blank, and the changelog MUST start on the third line.
1. To create a new release, you MUST create a git tag named as the exact
version string of the release. This kind of tag MUST be referred to as a
"release tag".
2. The release tag name can OPTIONALLY be prefixed with "v". For example the
tag name can be either "2.11.4" or "v2.11.4". It is however RECOMMENDED
that you do not use a "v" prefix. You MUST NOT use a mixture of "v"
prefixed and non-prefixed tags. Pick one form and stick to it.
3. If the version string is hard-coded into the code-base, you MUST create a
"version bump" commit which changes the hard-coded version string of the
project.
4. When using version bump commits, the release tag MUST be placed on the
version bump commit.
5. If you are not using a release branch, then the release tag, and if
relevant the version bump commit, MUST be created directly on the master
branch.
6. The version bump commit SHOULD have a commit message title of "Bump
version to VERSION". For example, if the new version string is "2.11.4",
the first line of the commit message SHOULD read: "Bump version to
2.11.4"
7. It is RECOMMENDED that release tags are lightweight tags, but you can
OPTIONALLY use annotated tags if you want to include changelog
information in the release tag itself.
8. If you use annotated release tags, the first line of the annotation
SHOULD read "Release VERSION". For example for version "2.11.4" the first
line of the tag annotation SHOULD read "Release 2.11.4". The second line
MUST be blank, and the changelog MUST start on the third line.
7. Short-Term Release Branches
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Any release branch which has a name ending with a specific version
string, MUST be referred to as a "short-term release branch".
3. Use of short-term release branches are OPTIONAL, and intended to be used
to create a specific versioned release.
4. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
5. Short-term release branches MUST have a name of "release-VERSION". For
example for version "2.11.4" the release branch name MUST be
"release-2.11.4".
6. When using a short-term release branch to create a release, the release
tag and if used, version bump commit, MUST be placed directly on the
short-term release branch itself.
7. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master branch,
and SHOULD be pulled into the release branch by rebasing it on top of the
master branch the same way a change branch pulls in updates from its
source branch.
8. After a release tag has been created, the release branch MUST be merged
back into its source branch and then deleted. Typically the source branch
will be the master branch.
1. Any branch that has a name starting with "release-" SHOULD be referred to
as a "release branch".
2. Any release branch which has a name ending with a specific version
string, MUST be referred to as a "short-term release branch".
3. Use of short-term release branches are OPTIONAL, and intended to be used
to create a specific versioned release.
4. A short-term release branch is RECOMMENDED if there is a lengthy
pre-release verification process to avoid a code freeze on the master
branch.
5. Short-term release branches MUST have a name of "release-VERSION". For
example for version "2.11.4" the release branch name MUST be
"release-2.11.4".
6. When using a short-term release branch to create a release, the release
tag and if used, version bump commit, MUST be placed directly on the
short-term release branch itself.
7. Only very minor changes should be performed on a short-term release
branch directly. Any larger changes SHOULD be done in the master branch,
and SHOULD be pulled into the release branch by rebasing it on top of the
master branch the same way a change branch pulls in updates from its
source branch.
8. After a release tag has been created, the release branch MUST be merged
back into its source branch and then deleted. Typically the source branch
will be the master branch.
8. Long-term Release Branches
1. Any release branch which has a name ending with a non-specific version
string, MUST be referred to as a "long-term release branch". For example
"release-2.11" is a long-term release branch, while "release-2.11.4" is a
short-term release branch.
2. Use of long-term release branches are OPTIONAL, and intended for work on
versions which are not currently part of the master branch. Typically
this is useful when you need to create a new maintenance release for a
older version.
3. A long-term release branch MUST have a name with a non-specific version
number. For example a long-term release branch for creating new 2.9.x
releases MUST be named "release-2.9".
4. Long-term release branches for maintenance releases of older versions
MUST be created from the relevant release tag. For example if the master
branch is on version 2.11.4 and there is a security fix for all 2.9.x
releases, the latest of which is "2.9.7". Create a new branch called
"release-2.9" from the "2.9.7" release tag. The security fix release will
then end up being version "2.9.8".
5. To create a new release from a long-term release branch, you MUST follow
the same process as a release from the master branch, except the
long-term release branch takes the place of the master branch.
6. A long-term release branch should be treated with the same respect as the
master branch. It is effectively the master branch for the release series
in question. Meaning it MUST always be in a non-broken state, MUST NOT be
force pushed to, etc.
1. Any release branch which has a name ending with a non-specific version
string, MUST be referred to as a "long-term release branch". For example
"release-2.11" is a long-term release branch, while "release-2.11.4" is a
short-term release branch.
2. Use of long-term release branches are OPTIONAL, and intended for work on
versions which are not currently part of the master branch. Typically
this is useful when you need to create a new maintenance release for a
older version.
3. A long-term release branch MUST have a name with a non-specific version
number. For example a long-term release branch for creating new 2.9.x
releases MUST be named "release-2.9".
4. Long-term release branches for maintenance releases of older versions
MUST be created from the relevant release tag. For example if the master
branch is on version 2.11.4 and there is a security fix for all 2.9.x
releases, the latest of which is "2.9.7". Create a new branch called
"release-2.9" from the "2.9.7" release tag. The security fix release will
then end up being version "2.9.8".
5. To create a new release from a long-term release branch, you MUST follow
the same process as a release from the master branch, except the
long-term release branch takes the place of the master branch.
7. A long-term release branch should be treated with the same respect as the
master branch. It is effectively the master branch for the release series
in question. Meaning it MUST always be in a non-broken state, MUST NOT be
force pushed to, etc.
9. Bug Fixes & Rollback
1. You MUST NOT under any circumstances force push to the master branch or
to long-term release branches.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
1. You MUST NOT under any circumstances force push to the master branch or
to long-term release branches.
2. If a change branch which has been merged into the master branch is found
to have a bug in it, the bug fix work MUST be done as a new separate
change branch and MUST follow the same workflow as any other change
branch.
3. If a change branch is wrongfully merged into master, or for any other
reason the merge must be undone, you MUST undo the merge by reverting the
merge commit itself. Effectively creating a new commit that reverses all
the relevant changes.
10. Git Best Practices
1. All commit messages SHOULD follow the Commit Guidelines and format from
the official git
@@ -252,7 +254,8 @@ interpreted as described in [RFC 2119](https://tools.ietf.org/html/rfc2119).
and creates a merge commit to mark the integration of the branch with
master.
## FAQ
FAQ
---
### Why use Common-Flow instead of Git Flow, and how does it differ?
@@ -341,7 +344,8 @@ complicated task and you're short on time, a short-term release branch gives you
a instant fix to the situation at hand, and let's you resolve the issues with
the master branch when you have more time on your hands.
## About
About
-----
The Git Common-Flow specification is authored
by [Jim Myhrberg](https://jimeh.me/).
@@ -349,6 +353,7 @@ by [Jim Myhrberg](https://jimeh.me/).
If you'd like to leave feedback,
please [open an issue on GitHub](https://github.com/jimeh/common-flow/issues).
## License
License
-------
[Creative Commons - CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

View File

@@ -14,9 +14,10 @@ import { parseSpecContent } from "../utils/parseSpecContent";
interface Props {
spec: CollectionEntry<"spec">;
versions: string[];
}
const { spec } = Astro.props;
const { spec, versions } = Astro.props;
const version = spec.data.version;
// Read the markdown file
@@ -31,10 +32,10 @@ const parsed = await parseSpecContent(markdown, version);
---
<BaseLayout title={spec.data.title}>
<Header version={version} />
<Header version={version} versions={versions} />
<main>
<Hero version={version} svgPath={parsed.svgPath} />
<Hero version={version} versions={versions} svgPath={parsed.svgPath} />
<AboutSection
introduction={parsed.introduction}

View File

@@ -2,16 +2,16 @@
import { getCollection } from "astro:content";
import SpecLayout from "../layouts/SpecLayout.astro";
import { config } from "../config";
import { getVersionInfo } from "../utils/versions";
// Render the current/latest version
const version = config.currentVersion;
// Get version info and render the current/latest version
const { versions, currentVersion } = await getVersionInfo();
const specs = await getCollection("spec");
const spec = specs.find((s) => s.data.version === version);
const spec = specs.find((s) => s.data.version === currentVersion);
if (!spec) {
throw new Error(`Spec version ${version} not found`);
throw new Error(`Spec version ${currentVersion} not found`);
}
---
<SpecLayout spec={spec} />
<SpecLayout spec={spec} versions={versions} />

View File

@@ -2,6 +2,7 @@
import { getCollection } from "astro:content";
import SpecLayout from "../../layouts/SpecLayout.astro";
import { getVersionInfo } from "../../utils/versions";
export async function getStaticPaths() {
const specs = await getCollection("spec");
@@ -12,6 +13,7 @@ export async function getStaticPaths() {
}
const { spec } = Astro.props;
const { versions } = await getVersionInfo();
---
<SpecLayout spec={spec} />
<SpecLayout spec={spec} versions={versions} />

View File

@@ -315,13 +315,9 @@ export async function parseSpecContent(
// Parse markdown to AST
const tree = unified().use(remarkParse).parse(markdown) as Root;
// Remove title (h1) and SVG image from the tree
// Remove title (h1) from the tree - it's displayed separately in the Hero
const nodes = tree.children.filter((node) => {
if (node.type === "heading" && (node as Heading).depth === 1) return false;
if (node.type === "paragraph") {
const text = extractText(node);
if (text.includes(".svg")) return false;
}
return true;
});

48
src/utils/versions.ts Normal file
View File

@@ -0,0 +1,48 @@
import { getCollection } from "astro:content";
import * as semver from "semver";
import { config } from "../config";
export interface VersionInfo {
versions: string[];
currentVersion: string;
}
/**
* Get version information derived from available spec files.
* Returns all versions sorted newest-first and determines the current version.
*/
export async function getVersionInfo(): Promise<VersionInfo> {
const specs = await getCollection("spec");
const versions = specs
.map((s) => s.data.version)
.filter((v): v is string => semver.valid(v) !== null)
.sort((a, b) => semver.rcompare(a, b)); // newest first
const currentVersion =
config.currentVersionOverride ?? determineCurrentVersion(versions);
return { versions, currentVersion };
}
/**
* Determine the current version based on priority:
* 1. Latest stable version
* 2. Latest RC version
* 3. Newest available version
*/
function determineCurrentVersion(versions: string[]): string {
// Priority order: stable (null prerelease) first, then rc
const priority: (string | null)[] = [null, "rc"];
for (const type of priority) {
const match = versions.find((v) => {
const pre = semver.prerelease(v);
if (type === null) return pre === null;
return pre?.[0] === type;
});
if (match) return match;
}
// Fallback to newest overall
return versions[0] ?? "";
}