-
Notifications
You must be signed in to change notification settings - Fork 398
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
FR: support running in the working copy for jj fix
#3808
Comments
I'm partial to the run/fix distinction being equivalent to the per-working-copy/per-file distinction, but mostly due to familiarity with such an implementation for The The
I should read more about |
Do you see either |
Yes. Here's my most common workflows:
In practice, many (all?) of these benefit from configuring the search behavior (git-branchless-test supports the following behaviors):
The majority of my usage is on my local commit stacks, not historical commits, so I don't have much to say about the relation to
I don't see why a user would consider fixing via per-file or per-working copy to be relevant for the UI.
The main distinction for me as a user in practice is whether a fix is "slow" or "fast".
Per-file vs per-working-copy fixes are roughly correlated to be "fast" vs "slow", but not always.
|
User surveyI surveyed a couple of users in Discord about their mental models. NOTE: The transcripts below are not verbatim; I removed and reordered messages to try to follow the individual threads. Question 1 (Discord link):@arxanas: When you consider a command called jj fix, what is your first impression in terms of what the command would be able to do/what the scope would be? @tingerrr responses:
@jennings responses:
Question 2 (Discord link):@arxanas: Do you expect that modifications dumped into the working copy with jj run will be automatically reflected in the caller (like it'll do the same rewrites as jj fix), or would you have to do something else to indicate that you want the changes to be reflected outside the jj run working copy? (Or, opposite, do you expect that there are cases that jj run changes to the working copy should be discarded/ignored?) Like do you imagine yourself using jj run with commands that don't modify the working copy? @tingerrr responses:
@jennings responses:
Question 3 (Discord link):@arxanas: By default, would you expect jj fix to operate on all files in the working copy, or only files changed in the commit? @tingerrr responses:
Takeaways
Compared to my original mental model:
|
Thanks @arxanas for summarizing all that. I obviously haven't thought about this as deeply as y'all have, but if I were building these features, I think this is how I would go about it: Phase 1: Implement the most general version of
|
My first impression of I don't expect that I don't think |
To be clear, the main reason Fortunately, I think we have a lot of convergent thinking on many aspects. I keep seeing hypothetical statements that sound like what I've been thinking. I've attempted to arrange the many desired behaviors into a small-ish set of orthogonal-ish dimensions, in the spirit of making I also hope that this provides a framework for phased implementation, where we implement the default behavior of each flag first, and fill in combinations over time. Dimensions with some hypothetical enumerations:
I'm not sure what the flags for each dimension should look like exactly. We can either make exclusivity obvious with --thing=foo|bar, or make it sugary with --foo-thing|--bar-thing. I'm not sure if we have a strong precedent for this in the CLI. In fact, that may even be a reason to not design it this way. I have some thoughts on how this would map to implementation, but I wanted to post this before I spend too much time on that. I think it could make good use of a planning phase that considers the flags and generically feeds instructions into a queue that is consumed by a worker pool that doesn't concern itself with flags. Instructions would include some arrangement of things like materializing working copies, executing subprocesses in working copies, passing file contents through subprocesses, rewriting commits with a As an aside, this is a complicated feature. I think it is worthwhile in its entirety, but we should honestly consider if it's not. If we scope it down, we cede more territory to third party extensions, and allow the functionality to develop in a more fragmented way (for better or worse). Maybe the incoming governance structure can weigh in on that. |
If existing tools have |
@joyously posted responses to the questions here. @emilazy posted responses to the questions in the Discord, reproduced below: Question 1@arxanas: When you consider a command called jj fix, what is your first impression in terms of what the command would be able to do/what the scope would be? @emilazy responses:
Question 2@arxanas: Do you expect that modifications dumped into the working copy with jj run will be automatically reflected in the caller (like it'll do the same rewrites as jj fix), or would you have to do something else to indicate that you want the changes to be reflected outside the jj run working copy? (Or, opposite, do you expect that there are cases that jj run changes to the working copy should be discarded/ignored?) Like do you imagine yourself using jj run with commands that don't modify the working copy? @emilazy responses:
|
That last point about "seeing changes made in previous commits" is important. It could either be considered as another dimension, or part of the "scope" dimension from my last comment. A couple of things seem clearer now:
I also generally agree with the idea that I don't think anyone contradicted this, but I want to point out that Another rabbit hole is that |
I think it may be worth mentioning here that some formatting scenarios, even with formatters that support in-memory use are not, to my knowledge, possible to sensibly set up with For prettier, say, you can get around the configuration by adding a repo-specific setting where you give arguments to prettier (and change them if the in-repo config is ever changed), and get around the ignore file by specifying the paths manually, but it's non-ideal and requires you to remember whether a file should be formatted. |
Is your feature request related to a problem? Please describe.
jj fix
(/hg fix
) are currently specialized towards formatters. However, these formatters have to operate in-memory on single files, which limits the utility somewhat.For context,
git-branchless-test fix
is implemented to operate on working copies, which I find quite useful in practice.There are several cases where you would prefer the full flexibility of running in the working copy:
jj fix --exec 'cargo fmt'
without any complicated configuration.pre-commit
checks.jj fix --exec 'cargo clippy --fix'
.git-branchless-submit
works with Phabricator: it runsarc diff
and actually amends the commit message with the effective change ID (the Phabricator URL).Describe the solution you'd like
jj fix
can operate in the working copy, similar to existing designs forjj run
. It would ideally be able to run in the current workspace, or in parallel across multiple workspaces.Describe alternatives you've considered
--fix
flag tojj run
instead. That's kind of weird because "fixes" are more or less the same thing to the user, so there's no reason to arbitrarily split them up into two different subcommands.The text was updated successfully, but these errors were encountered: