mirror of
https://github.com/sbrow/envr.git
synced 2026-08-26 18:03:32 -04:00
Compare commits
3 Commits
v0.4.0
..
af1860c970
| Author | SHA1 | Date | |
|---|---|---|---|
| af1860c970 | |||
| 5282a4414b | |||
| ea1627ec2e |
@@ -2,7 +2,7 @@
|
|||||||
# Builds release artifacts for GitHub releases
|
# Builds release artifacts for GitHub releases
|
||||||
|
|
||||||
APP_NAME := envr
|
APP_NAME := envr
|
||||||
VERSION := $(shell grep 'version = ' flake.nix | head -1 | sed 's/.*version = "\(.*\)";/\1/')
|
VERSION := $(file < version.txt)
|
||||||
BUILD_DIR := builds
|
BUILD_DIR := builds
|
||||||
|
|
||||||
# Binary names
|
# Binary names
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ key somewhere, otherwise your data could be lost forever.`,
|
|||||||
"Generate custom completions for nushell",
|
"Generate custom completions for nushell",
|
||||||
"",
|
"",
|
||||||
{},
|
{},
|
||||||
GLOBAL_FLAGS - {.Color},
|
{.Help},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import "base:runtime"
|
|||||||
import "core:crypto/hash"
|
import "core:crypto/hash"
|
||||||
import "core:encoding/hex"
|
import "core:encoding/hex"
|
||||||
import "core:encoding/ini"
|
import "core:encoding/ini"
|
||||||
import "core:encoding/json"
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
@@ -222,7 +221,6 @@ db_list :: proc(db: ^Db) -> ([]EnvFile, bool) {
|
|||||||
allocator := db_allocator(db)
|
allocator := db_allocator(db)
|
||||||
results := make([dynamic]EnvFile, 0, 10, allocator)
|
results := make([dynamic]EnvFile, 0, 10, allocator)
|
||||||
|
|
||||||
migrate := false
|
|
||||||
for {
|
for {
|
||||||
rc = sqlite.step(stmt)
|
rc = sqlite.step(stmt)
|
||||||
if rc == sqlite.DONE {
|
if rc == sqlite.DONE {
|
||||||
@@ -233,24 +231,13 @@ db_list :: proc(db: ^Db) -> ([]EnvFile, bool) {
|
|||||||
#no_bounds_check return results[:], false
|
#no_bounds_check return results[:], false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove json support after next major release
|
|
||||||
remotes: [dynamic]string = ---
|
|
||||||
remotes_raw := string(sqlite.column_text(stmt, 1))
|
remotes_raw := string(sqlite.column_text(stmt, 1))
|
||||||
if len(remotes_raw) > 0 {
|
|
||||||
if remotes_raw[0] == '[' {
|
|
||||||
err := json.unmarshal_string(remotes_raw, &remotes, allocator = allocator)
|
|
||||||
if err != nil {
|
|
||||||
fmt.eprintf("Warning: malformed remotes JSON: %v\n", err)
|
|
||||||
}
|
|
||||||
migrate = true
|
|
||||||
} else {
|
|
||||||
split := strings.split_lines(remotes_raw, context.temp_allocator)
|
split := strings.split_lines(remotes_raw, context.temp_allocator)
|
||||||
remotes = make([dynamic]string, 0, len(split), allocator = allocator)
|
remotes := make([dynamic]string, 0, len(split), allocator = allocator)
|
||||||
for s in split {
|
for s in split {
|
||||||
append(&remotes, strings.clone(s, allocator))
|
append(&remotes, strings.clone(s, allocator))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
path := clone_cstring(sqlite.column_text(stmt, 0), allocator)
|
path := clone_cstring(sqlite.column_text(stmt, 0), allocator)
|
||||||
|
|
||||||
append(
|
append(
|
||||||
@@ -265,10 +252,6 @@ db_list :: proc(db: ^Db) -> ([]EnvFile, bool) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if migrate {
|
|
||||||
migrate_remotes(db)
|
|
||||||
}
|
|
||||||
|
|
||||||
#no_bounds_check return results[:], true
|
#no_bounds_check return results[:], true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,33 +347,15 @@ db_fetch :: proc(db: ^Db, path: string) -> (EnvFile, bool) {
|
|||||||
return EnvFile{}, false
|
return EnvFile{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove json support after next major release
|
|
||||||
migrate := false
|
|
||||||
remotes: [dynamic]string = ---
|
|
||||||
remotes_raw := string(sqlite.column_text(stmt, 1))
|
remotes_raw := string(sqlite.column_text(stmt, 1))
|
||||||
if len(remotes_raw) > 0 {
|
|
||||||
if remotes_raw[0] == '[' {
|
|
||||||
err := json.unmarshal_string(remotes_raw, &remotes, allocator = allocator)
|
|
||||||
if err != nil {
|
|
||||||
fmt.eprintf("Warning: malformed remotes JSON: %v\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
migrate = true
|
|
||||||
} else {
|
|
||||||
split := strings.split_lines(remotes_raw, context.temp_allocator)
|
split := strings.split_lines(remotes_raw, context.temp_allocator)
|
||||||
remotes = make([dynamic]string, 0, len(split), allocator = allocator)
|
remotes := make([dynamic]string, 0, len(split), allocator = allocator)
|
||||||
for s in split {
|
for s in split {
|
||||||
append(&remotes, strings.clone(s, allocator))
|
append(&remotes, strings.clone(s, allocator))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file_path := clone_cstring(sqlite.column_text(stmt, 0), allocator)
|
file_path := clone_cstring(sqlite.column_text(stmt, 0), allocator)
|
||||||
|
|
||||||
if migrate {
|
|
||||||
migrate_remotes(db)
|
|
||||||
}
|
|
||||||
|
|
||||||
return EnvFile {
|
return EnvFile {
|
||||||
path = file_path,
|
path = file_path,
|
||||||
dir = filepath.dir(file_path),
|
dir = filepath.dir(file_path),
|
||||||
@@ -525,27 +490,6 @@ db_persist :: proc(db: ^Db, f: ^EnvFile, old_path: string) -> bool {
|
|||||||
return db_insert(db, f^)
|
return db_insert(db, f^)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remove after the next major release
|
|
||||||
migrate_remotes :: proc(db: ^Db) {
|
|
||||||
sql ::
|
|
||||||
"UPDATE envr_env_files " +
|
|
||||||
"SET remotes = COALESCE((" +
|
|
||||||
" SELECT group_concat(atom, char(10)) " +
|
|
||||||
" FROM json_each(envr_env_files.remotes)" +
|
|
||||||
"), '') " +
|
|
||||||
"WHERE remotes LIKE '[%'"
|
|
||||||
|
|
||||||
rc := sqlite.exec(db.conn, sql, nil, nil, nil)
|
|
||||||
if rc != sqlite.OK {
|
|
||||||
fmt.eprintf("Warning: failed to migrate remotes: %s\n", sqlite.errmsg(db.conn))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if sqlite.changes(db.conn) > 0 {
|
|
||||||
db.changed = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try_move_dir :: proc(db: ^Db, f: ^EnvFile, allocator: mem.Allocator) -> (bool, SyncError) {
|
try_move_dir :: proc(db: ^Db, f: ^EnvFile, allocator: mem.Allocator) -> (bool, SyncError) {
|
||||||
roots, ok := find_git_roots(db.cfg)
|
roots, ok := find_git_roots(db.cfg)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
packages.default = pkgs.stdenv.mkDerivation rec {
|
packages.default = pkgs.stdenv.mkDerivation rec {
|
||||||
pname = "envr";
|
pname = "envr";
|
||||||
version = "0.3.0";
|
version = nixpkgs.lib.trim (builtins.readFile ./version.txt);
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
|||||||
Reference in New Issue
Block a user