Commit graph

15 commits

Author SHA1 Message Date
Martin von Zweigbergk
b409aa3189 colocation: rename from "colocated repo" to "colocated workspace"
Colocation is about sharing the working copy between jj and git. It's
less important where the repo is stored. I therefore think we should
not call it "colocated repo". I considered renaming it to "colocated
working copy" but that sounded awkward in many places because we often
talk about the whole workspace (repo + working copy), so "In colocated
workspaces with a very large number of branches or other refs" sounds
better than "In colocated working copies with a very large number of
branches or other refs".

Once we support colocate workspaces in non-main Git worktrees, I think
this rename will be even more relevant because then all those
workspaces share the same repo but only some of them may be colocated.
2025-11-03 16:53:26 +00:00
Yuya Nishihara
744631d2bf cleanup: use method version of str::from_utf8()
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
MSRV is now 1.88.

https://doc.rust-lang.org/stable/std/primitive.str.html#method.from_utf8
2025-09-27 09:26:05 +00:00
Ivan Petkov
736f9bb5f7 cli: rewrite get_git_hash_from_jj in a functional style
Some checks are pending
binaries / Build binary artifacts (push) Waiting to run
website / prerelease-docs-build-deploy (ubuntu-24.04) (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
2025-09-25 05:06:04 +00:00
Ivan Petkov
c6df4e1a48 cli: rewrite get_git_hash_from_git in a functional style 2025-09-25 05:06:04 +00:00
Ivan Petkov
4630c3fda3 cli: lazily emit cargo:rerun-if-changed to avoid spurious rebuilds
The build script has a hierarchy of where the current git hash is
detected from: check $NIX_JJ_GIT_HASH, if that fails, ask jj, if that
fails, ask git.

If the build script is satisfied from a query higher up the priority
chain, there's no reason to instruct cargo to rereun and rebuild (and
relink) everything: for example if $NIX_JJ_GIT_HASH is set, there's no
need to check heads from either jj or git.

Although the build script takes effort to specify `jj log
--ignore-working-copy`, it would previously still get invalidated if jj
performed a snapshot (even if $NIX_JJ_GIT_HASH was set). This can be
fairly annoying when iterating on the test suite where each commit would
rebuild the CLI and by extension all of its tests.
2025-09-25 05:06:04 +00:00
Ivan Petkov
502eaca157 cli: split each git hash source into its own build script function 2025-09-25 05:06:04 +00:00
Austin Seipp
419bd51496 cargo: bump MSRV to 1.88
1.90 was just released, so this seems reasonable, and it finally lets us
use let-chains. This includes all the clippy fixups too, and some small
changes suggested by Ilya.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
2025-09-19 01:03:21 +00:00
Ilya Grigoriev
083fdaac60 build.rs: separate commit ids if compiling at a merge commit
This makes the `test_version` test failure when run at a merge commit
less confusing. The test could be fixed, but I'm not sure it's worth it,
as we probably don't want to release a version of `jj` compiled at a
merge commit.

Now, if `jj` is compiled at a merge commit, this would print:

```
$ jj --version
jj 0.31.0-fb10a78cb359d52c0eda518a42ab07f117909004-ff9c9d0d8b4e929843eb683709fc1717645796df-99e035c5054e71906d7293ed98b542a9055057ef
```

Admittedly, this is a bit of a quick hack, but I've been confused by
`jj --version` output when compiled at a merge commit enough times
to want it.

Prior art: https://github.com/jj-vcs/jj/pull/6311 and
https://github.com/jj-vcs/jj/pull/4033 both pick one commit id hash
to print. I think I prefer printing all of them, even if it will fail
tests at a merge commit. After this commit, the failure will at least
be easy to understand.

However, if we prefer to merge one of the others, I'm OK with that too.
2025-07-08 02:38:21 +00:00
Martin von Zweigbergk
e4bf147164 build: fix cargo publish by symlinking cli/docs->docs
I think `cargo publish` will currently fail because of the
`include_str!()` in `cli/src/commands/help.rs` pointing to
`../../../docs/`, i.e. outside of the crate directory. This patch
attempts to fix that creating a `cli/docs` symlink to `docs` and makes
the `include_str!` use that symlink. I hope the symlink will be
resolved at `cargo publish` time so it also works in the published
crate.

Because symlinks don't work well on Windows, I updated `cli/build.rs`
to include the original path (the one pointing outside the crate) if
`cli/docs` is not a symlink, so the regular build still should work on
Windows (but `cargo publish` won't).

Thanks to Yuya for proposing this solution.
2024-11-05 17:37:14 -08:00
Samuel Tardieu
46e2723464 style: inline variables into format strings 2024-10-04 22:29:13 +02:00
Samuel Tardieu
794db9dae0 style: do not return a Result when this is not needed 2024-10-04 22:29:13 +02:00
Kaleb Pace
dbb579adec cli/build-rs: remove metadata command dependency in favor of env vars
When building this project with [Nix/Crane](https://github.com/ipetkov/crane/discussions/693), if the `jj-cli` dependency is specified in `Cargo.toml` as a git-based crate, `cargo vendor` splits this workspace up into sub-crate directories, which causes `cargo metadata` to fail when searching for relative deps in the workspace root.

This commit simply changes how the crate version is determined, using Cargo's built-in environment variable [`CARGO_PKG_VERSION`](https://doc.rust-lang.org/cargo/reference/environment-variables.html)
2024-09-03 22:31:17 -07:00
Yuya Nishihara
5e22e67584 build: update rerun-if conditions to watch .git/HEAD in colocated repo
Since .git/HEAD is less frequently updated, this should avoid unneeded
recompilation on test-only changes. This only applies to colocated repo.
For non-colocated repo, maybe we can watch src/ and ../lib/src files?

This also adds $NIX_JJ_GIT_HASH to reflect hash changes (and to not rerun
if no .git nor .jj directory exists.)
2023-08-06 12:16:11 +09:00
Martin von Zweigbergk
aae14b24e0 build: in cli build script, fix relative path to root
Since the recent move of `builds.rs` to `cli/build.rs`, incremental
builds re-calcuate the version number and thus result in some
re-compilation and lots of re-linking.
2023-08-05 06:47:02 +00:00
Austin Seipp
48fa821e60 cli: move src/ directory to new cli/ directory
Summary: In preparation for unifying all workspace dependencies across all
crates, let's go ahead and move the jj-cli crate into its own new directory.
This will also be a nicer and more uniform layout as we add new `jj-*` crates.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
Change-Id: Icf94e7ae5f290dc8e181215727b38ada
2023-08-04 19:00:42 -05:00
Renamed from build.rs (Browse further)