Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(update): add update by environment variable #1

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ohsnap.zig
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ pub const Snap = struct {
pub fn diff(snapshot: *const Snap, got: []const u8, test_it: bool) !void {
// Check for an update first
const update_idx = std.mem.indexOf(u8, snapshot.text, "<!update>");
const update_envvar = std.process.hasEnvVarConstant("SNAP_UPDATE");

if (update_envvar) {
const match = regex_finder.match(snapshot.text);
if (match) |_| {
return try patchAndUpdate(snapshot, got);
} else {
return try updateSnap(snapshot, got);
}
}

if (update_idx) |idx| {
if (idx == 0) {
const match = regex_finder.match(snapshot.text);
Expand Down