Skip to content

add new command to easily rename a git-repository#1404

Merged
notheotherben merged 9 commits intomainfrom
feature/cedi/rename-repo
Mar 27, 2025
Merged

add new command to easily rename a git-repository#1404
notheotherben merged 9 commits intomainfrom
feature/cedi/rename-repo

Conversation

@cedi
Copy link
Copy Markdown
Collaborator

@cedi cedi commented Mar 21, 2025

this PR adds the functionality to rename git repositories and automatically change the upstream URL.

For example, given a repository layout of

~/
└ src/
  └ gh/
    └ SierraSoftworks/
      └ git-tool (origin git@github.com:SierraSoftworks/git-tool.git)

running

gt mv gh:SierraSoftworks/git-tool gh:SierraSoftworks/gt

will result in

~/
└ src/
  └ gh/
    └ SierraSoftworks/
      └ gt (origin git@github.com:SierraSoftworks/gt.git)

However, if you wish to only update the repository locally, you can specify --no-update-remote:

gt mv gh:SierraSoftworks/git-tool gh:SierraSoftworks/gt

will result in

~/
└ src/
  └ gh/
    └ SierraSoftworks/
      └ gt (origin git@github.com:SierraSoftworks/git-tool.git)

leaving the origin URL in tact

@github-actions github-actions bot added the feature A new feature for Git-Tool label Mar 21, 2025
Copy link
Copy Markdown
Member

@notheotherben notheotherben left a comment

Choose a reason for hiding this comment

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

This looks like a really neat addition - up until now I've generally done a mv <repo> && cd <repo> && gt fix but this is much cleaner and (especially if we integrate it with the GitHub API) would save me a lot of time organizing things.

One major downside: it's going to contribute to naming indecision and result in me changing repo names far more regularly 😂 (a nice problem to have).

Comment thread src/commands/rename.rs Outdated
Comment thread src/core/repo.rs Outdated
Comment thread src/core/repo.rs Outdated
Comment thread src/git/remote.rs Outdated
Comment thread src/tasks/git_remote.rs Outdated
Comment thread src/commands/rename.rs
Comment thread src/commands/rename.rs
fn app(&self) -> clap::Command {
clap::Command::new(self.name())
.about("renames a repository on your local machine")
.long_about("This command will rename the specified repository on your local machine. It requires that the repository name be provided in fully-qualified form.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(Optional) I think it would be really cool to have this command tie into the online::service::github stuff to enable renaming of GitHub repositories automatically.

That'd likely need a new task::RenameRemote to mirror the existing task::CreateRemote and we probably want to add a config flag + a command line argument to control the behaviour if we do so.

If we did build that, I suspect we'd need to be pretty clever as well about determining a few things:

  1. Are both repos part of the same service?
  2. Are both repos part of the same namespace? (If so, rename the repo)
  3. Are both repos part of different namespaces? (If so, transfer the repo)

The cool part is that if we built that on the existing online::services::* machinery, it would be pretty straightforward to extend it to support other services in future - and it'll automatically support GitHub Enterprise too.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2025

Codecov Report

Attention: Patch coverage is 89.16409% with 70 lines in your changes missing coverage. Please review.

Project coverage is 84.94%. Comparing base (8a21b46) to head (eafe3e8).
Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/commands/rename.rs 86.60% 41 Missing ⚠️
src/tasks/move_directory.rs 90.37% 13 Missing ⚠️
src/git/cmd.rs 0.00% 9 Missing ⚠️
src/tasks/git_move_upstream.rs 95.56% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1404      +/-   ##
==========================================
+ Coverage   84.59%   84.94%   +0.34%     
==========================================
  Files          93       96       +3     
  Lines        9497    10136     +639     
==========================================
+ Hits         8034     8610     +576     
- Misses       1463     1526      +63     
Files with missing lines Coverage Δ
src/commands/mod.rs 50.00% <ø> (ø)
src/core/target.rs 45.16% <ø> (ø)
src/git/remote.rs 100.00% <100.00%> (ø)
src/tasks/mod.rs 60.00% <ø> (ø)
src/tasks/git_move_upstream.rs 95.56% <95.56%> (ø)
src/git/cmd.rs 20.00% <0.00%> (-2.23%) ⬇️
src/tasks/move_directory.rs 90.37% <90.37%> (ø)
src/commands/rename.rs 86.60% <86.60%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/tasks/move_directory.rs
Comment thread src/tasks/move_directory.rs Outdated
Comment thread src/tasks/move_directory.rs Outdated
Comment thread src/commands/rename.rs Outdated
@cedi cedi force-pushed the feature/cedi/rename-repo branch from 744860d to 2064ca0 Compare March 27, 2025 19:31
@cedi cedi changed the title add new command to easily rename a git-repository wip: add new command to easily rename a git-repository Mar 27, 2025
@github-actions github-actions bot added the docs Changes to the documentation label Mar 27, 2025
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://brave-meadow-00ba9e303-1404.westeurope.1.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://brave-meadow-00ba9e303-1404.westeurope.1.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://brave-meadow-00ba9e303-1404.westeurope.1.azurestaticapps.net

@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://brave-meadow-00ba9e303-1404.westeurope.1.azurestaticapps.net

Comment thread src/tasks/git_move_upstream.rs
Comment thread src/tasks/git_move_upstream.rs
Comment thread src/tasks/git_move_upstream.rs
Comment thread src/tasks/move_directory.rs Outdated
@github-actions
Copy link
Copy Markdown

Azure Static Web Apps: Your stage site is ready! Visit it here: https://brave-meadow-00ba9e303-1404.westeurope.1.azurestaticapps.net

@cedi cedi changed the title wip: add new command to easily rename a git-repository add new command to easily rename a git-repository Mar 27, 2025
@notheotherben notheotherben merged commit db8da7f into main Mar 27, 2025
14 checks passed
@notheotherben notheotherben deleted the feature/cedi/rename-repo branch March 27, 2025 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Changes to the documentation feature A new feature for Git-Tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants