Compare commits
No commits in common. "14025cbc99d4cdc754d054c098a991d8c985a739" and "6b93e2178b61ae8492d4f25a136c6f180293b2db" have entirely different histories.
14025cbc99
...
6b93e2178b
|
|
@ -11,7 +11,9 @@
|
||||||
env.NIX_LDFLAGS = "-lXcursor";
|
env.NIX_LDFLAGS = "-lXcursor";
|
||||||
});
|
});
|
||||||
ki = super.ki.overrideAttrs (old: {
|
ki = super.ki.overrideAttrs (old: {
|
||||||
patches = old.patches ++ [./ki.diff];
|
postInstall = ''
|
||||||
|
patch $out/bin/ki < ${./ki.diff}
|
||||||
|
'';
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,75 +1,11 @@
|
||||||
diff --git a/ki/__init__.py b/ki/__init__.py
|
--- a/bin/ki
|
||||||
index 3f29c1a..17c820c 100644
|
+++ b/bin/ki
|
||||||
--- a/ki/__init__.py
|
@@ -1,6 +1,8 @@
|
||||||
+++ b/ki/__init__.py
|
import re
|
||||||
@@ -405,7 +405,7 @@ def parse_note(parser: Lark, transformer: NoteTransformer, delta: Delta) -> Deck
|
import sys
|
||||||
deck=deck,
|
from ki import ki
|
||||||
model=flatnote.model,
|
+import ki.maybes as M; M.empty_kirepo = lambda root: (M.F.mksubdir(root, M.Path(M.KI)), M.F.mksubdir(M.EmptyDir(root), M.Path(M.MEDIA)))
|
||||||
tags=flatnote.tags,
|
+import pathlib as P; PTD = P.Path.__truediv__; P.Path.__truediv__ = lambda a, b: P.Path('/dev/null') if '.gitattributes' in str(PTD(a, b)) else PTD(a, b)
|
||||||
- fields=flatnote.fields,
|
if __name__ == "__main__":
|
||||||
+ fields={k: v.rstrip() for k, v in flatnote.fields.items()},
|
sys.argv[0] = re.sub(r"(-script\.pyw|\.exe)?$", "", sys.argv[0])
|
||||||
)
|
sys.exit(ki())
|
||||||
|
|
||||||
|
|
||||||
@@ -466,7 +466,7 @@ def update_note(
|
|
||||||
|
|
||||||
nid = note.id
|
|
||||||
note.tags = decknote.tags
|
|
||||||
- note.flush()
|
|
||||||
+ note.col.update_note(note)
|
|
||||||
|
|
||||||
# Set the deck of the given note, as well as all its cards, and create a
|
|
||||||
# deck with this name if it doesn't already exist. See the
|
|
||||||
@@ -496,7 +496,7 @@ def update_note(
|
|
||||||
warnings = map(lambda k: NoteFieldValidationWarning(nid, k, new_notetype), missing)
|
|
||||||
fields = [(key, field) for key, field in decknote.fields.items() if key in note]
|
|
||||||
stardo(update_field(decknote, note), fields)
|
|
||||||
- note.flush()
|
|
||||||
+ note.col.update_note(note)
|
|
||||||
|
|
||||||
# Remove if unhealthy.
|
|
||||||
fwarns: List[Warning] = check_fields_health(note)
|
|
||||||
@@ -1510,14 +1510,15 @@ def _pull2(kirepo: KiRepo, col: Collection) -> Collection:
|
|
||||||
|
|
||||||
|
|
||||||
@ki.command()
|
|
||||||
+@click.option('-f', '--force', is_flag=True)
|
|
||||||
@beartype
|
|
||||||
-def push() -> None:
|
|
||||||
+def push(force: bool) -> None:
|
|
||||||
"""Push commits from the currrent ki repository into an Anki collection."""
|
|
||||||
- _push()
|
|
||||||
+ _push(force)
|
|
||||||
|
|
||||||
|
|
||||||
@beartype
|
|
||||||
-def _push() -> PushResult:
|
|
||||||
+def _push(force: bool = False) -> PushResult:
|
|
||||||
"""Execute a push op."""
|
|
||||||
# pylint: disable=too-many-locals
|
|
||||||
# Check that we are inside a ki repository, and load collection.
|
|
||||||
@@ -1527,7 +1528,10 @@ def _push() -> PushResult:
|
|
||||||
hashes: List[str] = kirepo.hashes_file.read_text(encoding=UTF8).split("\n")
|
|
||||||
hashes = list(filter(lambda l: l != "", hashes))
|
|
||||||
if md5sum not in hashes[-1]:
|
|
||||||
- raise UpdatesRejectedError(kirepo.col_file)
|
|
||||||
+ if force:
|
|
||||||
+ echo('overwriting...')
|
|
||||||
+ else:
|
|
||||||
+ raise UpdatesRejectedError(kirepo.col_file)
|
|
||||||
|
|
||||||
head_kirepo: KiRepo = cp_ki(M.head_ki(kirepo), f"{HEAD_SUFFIX}-{md5sum}")
|
|
||||||
remote_root: EmptyDir = F.mksubdir(F.mkdtemp(), REMOTE_SUFFIX / md5sum)
|
|
||||||
diff --git a/ki/maybes.py b/ki/maybes.py
|
|
||||||
index 38c5573..45458f5 100644
|
|
||||||
--- a/ki/maybes.py
|
|
||||||
+++ b/ki/maybes.py
|
|
||||||
@@ -470,8 +470,6 @@ def empty_kirepo(root: EmptyDir) -> Tuple[EmptyDir, EmptyDir]:
|
|
||||||
"""Initialize subdirs for a ki repo."""
|
|
||||||
kidir = F.mksubdir(root, Path(KI))
|
|
||||||
mediadir = F.mksubdir(EmptyDir(root), Path(MEDIA))
|
|
||||||
- workflowsdir = F.mksubdir(EmptyDir(root), Path(".github/workflows"))
|
|
||||||
- _ = F.copyfile(F.chk(Path(__file__).parent / "jekyll-gh-pages.yml"), F.chk(workflowsdir / "jekyll-gh-pages.yml.example"))
|
|
||||||
return kidir, mediadir
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,15 +17,12 @@
|
||||||
"$git_metrics"
|
"$git_metrics"
|
||||||
"$git_status\\]](bold) )"
|
"$git_status\\]](bold) )"
|
||||||
|
|
||||||
"$python"
|
|
||||||
|
|
||||||
"$cmd_duration"
|
"$cmd_duration"
|
||||||
"$line_break"
|
"$line_break"
|
||||||
|
|
||||||
"$jobs"
|
"$jobs"
|
||||||
"$shlvl"
|
"$shlvl"
|
||||||
"$status"
|
"$status"
|
||||||
"\${env_var.FHS}"
|
|
||||||
"$nix_shell"
|
"$nix_shell"
|
||||||
"$character"
|
"$character"
|
||||||
];
|
];
|
||||||
|
|
@ -68,9 +65,6 @@
|
||||||
git_status.format = "(| [$all_status$ahead_behind]($style) )";
|
git_status.format = "(| [$all_status$ahead_behind]($style) )";
|
||||||
cmd_duration.format = "[\\[$duration\\]]($style) ";
|
cmd_duration.format = "[\\[$duration\\]]($style) ";
|
||||||
hostname.format = "[ @$hostname ](bg:c2)";
|
hostname.format = "[ @$hostname ](bg:c2)";
|
||||||
python.format = "([\\[$virtualenv\\]]($style) )";
|
|
||||||
env_var.FHS.variable = "FHS";
|
|
||||||
env_var.FHS.format = "[\\(fhs\\)](bold) ";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue