Skip to content

Conversation

@kemitix
Copy link
Contributor

@kemitix kemitix commented Oct 23, 2024

Description

Adds support for opening the Git repository used when a repository is cloned using Jujutsu and the --colocate option was NOT used.

Note: this requires that the user updates the HEAD of the git repository to point to their mainline branch, as the Git repository the Jujutsu creates isn't 100% configured.

If the .git directory can't be opened (usually because the .git directory is missing) it attempts to find the git repository in the location used by Jujutsu (i.e. .jj/repo/store/git). If the Jujutsu git directory doesn't exist, then the origin error is propogated.

Motivation and Context

Jujutsu is a Version Control System that uses Git as it's local store, and can work as an effective replacement for Git on a Developer's workstation.

When a Git repository is cloned by Jujutsu, the default location for the Git respository files is .jj/repo/store/git, rather than the usual .git. git-cliff expectes the .git location. This PR teaches git-cliff to also check the .jj/repo/store/git location.

Closes #875

How Has This Been Tested?

Test with Jujutsu repository:

  • Cloned a Git repository using Jujutsu: jj git clone git@git.kemitix.net:kemitix/git-next.git && cd git-next
  • Update the HEAD to point to the remote main branch: echo 'ref: refs/remotes/origin/main
  • Run git-cliff: ../git-cliff/target/debug/git-cliff

Regression test with a Git repository:

  • Cloned a Git repository using Jujutsu: git clone git@git.kemitix.net:kemitix/git-next.git git-next-git && cd git-next-git
  • Run git-cliff: ../git-cliff/target/debug/git-cliff

Screenshots / Logs (if applicable)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (no code change)
  • Refactor (refactoring production code)
  • Other

Checklist:

  • My code follows the code style of this project.
  • I have updated the documentation accordingly.
  • I have formatted the code with rustfmt.
  • I checked the lints with clippy.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@codecov-commenter
Copy link

codecov-commenter commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.14%. Comparing base (0fabf22) to head (d66ac8a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #930      +/-   ##
==========================================
+ Coverage   42.91%   43.14%   +0.23%     
==========================================
  Files          21       21              
  Lines        1713     1718       +5     
==========================================
+ Hits          735      741       +6     
+ Misses        978      977       -1     
Flag Coverage Δ
unit-tests 43.14% <100.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good starting point, thanks :)

@kemitix kemitix marked this pull request as ready for review October 27, 2024 18:28
kemitix and others added 2 commits October 29, 2024 08:25
If the .git directory can't be opened (usually because the `.git` directory is missing) it attempts to find the git repository in the location used by Jujutsu (i.e. `.jj/repo/store/git`). If the Jujutsu git directory doesn't exist, then the origin error is propogated.
CODE

test: add unit tests for opening jujutsu repo
Update git-cliff-core/src/repo.rs

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Update git-cliff-core/src/repo.rs

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Update git-cliff-core/src/repo.rs

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Update git-cliff-core/src/repo.rs

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
Copy link
Owner

@orhun orhun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

@orhun orhun merged commit ab95626 into orhun:main Nov 1, 2024
@kemitix kemitix deleted the jujutsu branch November 1, 2024 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for Jujutsu (when using git store)

3 participants