t27.aiРусский

A commit is a save point

You will learn

What a commit keeps, why editing afterwards cannot change it, and when to make one.

Vibecoding means an agent changes your files while you watch, and some changes break things. A commit is a save point: it keeps every file exactly as it was at that moment, and you can edit as much as you like afterwards, the saved copy does not change. In commit.t27 the file said 10 when it was committed; an agent then made it 99; going back returns 10, not 99. Each commit adds one save point to the history and overwrites nothing: after a third commit there are 3. Commit when the program runs, before you ask for the next change.

Try it

In the widget, read the value of the file at the three moments and find the one where the agent's edit is undone; then in the spec frame find RESTORED and say what would change if it were set to EDITED.

Open the interactive lesson →

A commit is a save point ↗

A file before and after an agent edits it, and what a commit lets you bring back. Lesson 7 of the course Vibecoding from zero with t27.

specs/vibecoding/commit.t27

// SPDX-License-Identifier: Apache-2.0
; specs/vibecoding/commit.t27 -- lesson "A commit is a save point" of the course "Vibecoding from zero with t27"
; A commit keeps your files exactly as they were at that moment. Edit later as much as you like:
; the saved copy does not change, and you can go back to it. Here a file is one number.
; ASCII only, English only.

module vibecoding_commit;

; The file when you committed, and the file after an agent changed it.
pub const SAVED : u8 = 10;
pub const EDITED : u8 = 99;

; What going back brings you: the saved copy, whatever the file says now.
pub const RESTORED : u8 = 10;

; Each commit adds one save point to the history; nothing is overwritten.
pub const COMMITS_BEFORE : u8 = 2;
pub const COMMITS_AFTER : u8 = 3;

test going_back_returns_the_saved_copy {
    assert RESTORED == SAVED;
}

test editing_does_not_touch_the_save {
    assert SAVED == 10;
    assert EDITED != SAVED;
}

test a_commit_adds_one_save_point {
    assert COMMITS_AFTER == COMMITS_BEFORE + 1;
}

; Negative control: plant the bug "going back reads the edit" (RESTORED = 99) and
; two tests turn red; with the line as written they stay green.
test negative_control_a_restore_is_not_the_edit {
    assert RESTORED != EDITED;
}

Open the lesson's spec in the player ↗

All lessons