topgrade icon indicating copy to clipboard operation
topgrade copied to clipboard

Support for jujutsu version control

Open Walther opened this issue 1 year ago • 1 comments

I want to suggest some general feature

Topgrade should have at least some support for the jujutsu version control system. It is a highly convenient, modern approach to the CLI experience of using a VCS.

More information

Full support for jujutsu specifically might be out of scope or something to consider adding later.

However, jj is git-compatible, and it is a common pattern to interact with git repositories using jj, using the colocation feature:

A "co-located" Jujutsu repo is a hybrid Jujutsu/Git repo. These can be created if you initialize the Jujutsu repo in an existing Git repo by running jj git init --colocate or with jj git clone --colocate. The Git repo and the Jujutsu repo then share the same working copy. Jujutsu will import and export from and to the Git repo on every jj command automatically.

I am a very happy user of topgrade and its git repositories feature 🧡 However, currently there's a tiny clash with colocated jj-and-git repositories:

It is allowed to mix jj and git commands in such a repo in any order. However, it may be easier to keep track of what is going on if you mostly use read-only git commands and use jj to make changes to the repo. One reason for this (see below for more) is that jj commands will usually put the git repo in a "detached HEAD" state, since in jj there is not concept of a "currently tracked branch". Before doing mutating Git commands, you may need to tell Git what the current branch should be with a git switch command.

Because of the detached HEAD state, topgrade will currently show me errors Failed pulling for any colocated jj-and-git repository I have.

The simplest possible minimal improvement could be to

  1. detect the presence of a .jj/ directory in addition to .git/
  2. instead of git pull, use jj git fetch or git fetch

Walther avatar Dec 31 '24 11:12 Walther

Possible inspiration from the Starship shell prompt: https://github.com/starship/starship/issues/5932

Walther avatar Feb 19 '25 07:02 Walther