summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-15 17:41:22 +0000
committerLars Wirzenius <liw@liw.fi>2021-09-15 17:41:22 +0000
commitcb77ffe8f3b61e5dd488d918b067efd28c07948e (patch)
tree487002380e31311809c161f4e5b09638f2f46ccf
parent794ea63e46212941e73ca3933d30431d43d469b3 (diff)
parent8165ec7c6b418e32ff8518ebd04d0344f2ab6c15 (diff)
downloadjt2-cb77ffe8f3b61e5dd488d918b067efd28c07948e.tar.gz
Merge branch 'fix-topic' into 'main'
fix topic names containing dots See merge request larswirzenius/jt!24
-rw-r--r--.gitlab-ci.yml2
-rwxr-xr-xcheck26
-rw-r--r--debian/control1
-rw-r--r--jt.md12
-rw-r--r--src/journal.rs4
-rw-r--r--subplot/jt.py3
6 files changed, 23 insertions, 25 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 93a8ac9..42a4224 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -6,7 +6,7 @@ build-job:
script:
- curl -s https://gitlab.com/subplot/subplot/-/raw/main/install-debian.sh | bash
- apt-get update
- - apt-get install -y black subplot texlive-latex-base texlive-latex-recommended texlive-fonts-recommended plantuml
+ - apt-get install -y black subplot texlive-latex-base texlive-latex-recommended texlive-fonts-recommended plantuml jq
- rustup component add clippy
- rustup component add rustfmt
- if ! ./check; then echo =====================; tail -n 500 test.log; exit 1; fi
diff --git a/check b/check
index c90afee..801c75c 100755
--- a/check
+++ b/check
@@ -3,26 +3,23 @@
set -eu
verbose=false
-if [ "$#" -gt 0 ]
-then
- case "$1" in
+if [ "$#" -gt 0 ]; then
+ case "$1" in
verbose | -v | --verbose)
- verbose=true
- shift
- ;;
- esac
+ verbose=true
+ shift
+ ;;
+ esac
fi
hideok=
-if command -v chronic > /dev/null
-then
- hideok=chronic
+if command -v chronic >/dev/null; then
+ hideok=chronic
fi
-if $verbose
-then
- hideok=
+if $verbose; then
+ hideok=
fi
$hideok cargo check --all-targets
@@ -38,6 +35,7 @@ $hideok subplot docgen jt.md --output jt.pdf
$hideok subplot codegen jt.md --output test.py
rm -f test.log
-$hideok python3 test.py --log test.log "$@"
+target="$(cargo metadata --format-version=1 | jq -r .target_directory)"
+$hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target" "$@"
echo "Everything seems to be in order."
diff --git a/debian/control b/debian/control
index 336dd98..332bbe5 100644
--- a/debian/control
+++ b/debian/control
@@ -8,6 +8,7 @@ Build-Depends:
build-essential,
black,
dh-cargo,
+ jq,
moreutils,
python3,
subplot,
diff --git a/jt.md b/jt.md
index 2066690..4fcea5d 100644
--- a/jt.md
+++ b/jt.md
@@ -310,19 +310,19 @@ given an installed jt
when I run jt --dirname jrnl init default "My test journal"
then command is successful
-when I try to run jt --editor=none --dirname=jrnl new --topic foo "Abracadabra"
+when I try to run jt --editor=none --dirname=jrnl new --topic foo.bar "Abracadabra"
then command fails
-then stderr contains "foo"
+then stderr contains "foo.bar"
-when I run jt --editor=none --dirname=jrnl new-topic foo "Things about Foo"
+when I run jt --editor=none --dirname=jrnl new-topic foo.bar "Things about Foobars"
then command is successful
-then file jrnl/foo.mdwn contains "Things about Foo"
+then file jrnl/foo.bar.mdwn contains "Things about Foobars"
then there are no uncommitted changes in jrnl
-when I run jt --editor=none --dirname=jrnl new --topic foo "Abracadabra"
+when I run jt --editor=none --dirname=jrnl new --topic foo.bar "Abracadabra"
then command is successful
and there is one draft in jrnl
-and draft 0 in jrnl links to "foo"
+and draft 0 in jrnl links to "foo.bar"
~~~
diff --git a/src/journal.rs b/src/journal.rs
index c12ebfa..a48a63d 100644
--- a/src/journal.rs
+++ b/src/journal.rs
@@ -223,9 +223,7 @@ fn is_dir(path: &Path) -> bool {
}
fn topic_path(dirname: &Path, topic: &Path) -> PathBuf {
- let mut path = dirname.join(topic);
- path.set_extension("mdwn");
- path
+ dirname.join(&format!("{}.mdwn", topic.display()))
}
fn current_timestamp() -> String {
diff --git a/subplot/jt.py b/subplot/jt.py
index dfdf44c..416e830 100644
--- a/subplot/jt.py
+++ b/subplot/jt.py
@@ -8,7 +8,8 @@ def install_jt(ctx):
runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
srcdir = globals()["srcdir"]
- bindir = os.path.join(srcdir, "target", "debug")
+ target = os.environ.get("CARGO_TARGET_DIR", os.path.join(srcdir, "target"))
+ bindir = os.path.join(target, "debug")
runcmd_prepend_to_path(ctx, bindir)
# Configure git.