Giter Site home page Giter Site logo

virtuslab / git-machete-intellij-plugin Goto Github PK

View Code? Open in Web Editor NEW
134.0 11.0 16.0 82.56 MB

Probably the sharpest git repository organizer & rebase/merge workflow automation tool you've ever seen

License: MIT License

Java 82.95% Shell 4.25% Dockerfile 0.22% JavaScript 2.35% Lex 0.20% HTML 0.10% Kotlin 7.09% Scala 2.71% Awk 0.12%
git intellij-plugin git-machete jetbrains-marketplace jetbrains-products intellij

git-machete-intellij-plugin's Introduction

Git Machete IntelliJ Plugin

CircleCI JetBrains Plugins Downloads License: MIT

๐Ÿ’ช Git Machete plugin is a robust tool that simplifies your git related workflow. It's a great complement to the JetBrains products' built-in version control system.

๐Ÿฆ… The bird's eye view provided by Git Machete makes merges/rebases/push/pulls hassle-free even when multiple branches are present in the repository (master/develop, your topic branches, teammate's branches checked out for review, etc.).

๐Ÿ‘ A look at a Git Machete tab gives an instant answer to the questions:

  • What branches are in this repository?
  • What is going to be merged (or rebased/pushed/pulled) and to what?

sample status with master, develop and a few topic branches

๐ŸŽฏ With this plugin, you can maintain small, focused, easy-to-review pull requests with little effort.

โš™ It is compatible with all JetBrains products (IntelliJ IDEA, PyCharm, Android Studio etc.). The latest plugin version is available for IDE versions from 2022.3 onwards.
Earlier plugin versions (which might not have all the latest features & fixes) are available for earlier IDE versions as well, starting from as early as 2020.1.

๐Ÿ–ฅ For the console version, check git-machete.

Installing from JetBrains Marketplace

This plugin is available on JetBrains Marketplace.
To install this plugin go to File > Settings > Plugins (Preferences/Settings > Plugins on macOS) in your IDE, then make sure you are on Marketplace tab (not Installed), in search box type Git Machete and click Install.
After installation, depending on the IDE version, the restart may be required. In that case, just click Restart IDE and confirm that action in a message box.

Where to find the plugin tab

Git Machete IntelliJ Plugin is available under the Git tool window in the Git Machete tab. You can find the Git tool window in the lower left corner of the screen.
You can also use Ctrl + Alt + Shift + M (โŒ˜โŒฅโ‡งM or ^โŒฅโ‡งM on macOS) shortcut to open it.

Getting started with Git Machete

The examples below show a few common situations where Git Machete proves exceptionally useful.

If you are a Git Master or have used the git-machete CLI already, you may want to jump directly to the features.

Scenario 1: Review

Let's start with a very common case of review. Suppose that you work on two branches: sticky-header and fancy-footer (you've split your work among these two branches to keep the PRs small and easily reviewable).

In the meantime, a teammate of yours requested a review of their PR for branch common-scripts...

Git Machete allows you to check out the remote branch with Slide In. Alternatively, you could check out it via git CLI or Git Branches widget in IntelliJ. Once the review is complete, you can simply check out any other branch from the right-click menu or by a double click โ€” master in the example.

Once the branch common-scripts is no longer needed for review, it can be slid out (Slide Out) โ€” deleted from the branch layout and optionally the branch can be removed from the local repository.

Scenario 2: Branch update

Some time passed and your teammate has merged the common-scripts before you managed to merge your branches. You are supposed to update master and your branches now.

Firstly, you can fetch all changes from the remote using Fetch All.
As you'd expect, your local master is behind its remote, so you perform Pull to get it in sync. Note that the pull via Git Machete plugin does not require checking out the given branch.

The edge between master and sticky-header turned red. It means that there are some commits belonging to the parent (master) branch that are not reachable from the child (sticky-header). In case of master, these commits came from the recently merged common-scripts.

To put sticky-header back in sync to master two options are available โ€” Checkout and Sync to Parent by Rebase ... or Checkout and Sync to Parent by Merge ... Fortunately, there are no conflicts to resolve.
Once sticky-header is rebased or merged, you can do the same for fancy-footer.

You may want to update the remotes as well. To do so, perform Push... for both of the branches. The push can be done even for a branch that is not currently checked out. Note that force push is required (as you have rebased the branches since the latest push).

After the rebases and pushes, all of your branches are back in sync โ€” both to their parents and to their remotes.

Scenario 3: Commit to parent branch (sequential branch setup)

A review of your sticky-header has been done and all you've applied and committed all the fixes.
Git Machete shows that sticky-header is ahead of its remote. Furthermore, the edge between sticky-header and fancy-footer is red. The solution to this situation will not differ much from the previous scenario...

You can start with Checkout and Sync to Parent by Rebase... to place fancy-footer back on top of sticky-header. Now Push... both branches. Everything is back in sync again.

Scenario 4: Merge (maintaining linear history)

A PR for your sticky-header branch has been approved and is ready to merge.
To make git revert & git bisect easier and generally simplify diagnostics & providing fixes in production settings, let's stick to linear git history and thus perform merges that do not produce the actual merge commits.
The way to go is to fast-forward merge sticky-footer into master.

Note that Fast-forward Merge into Parent does not require you to check out the branch getting merged (or its parent) beforehand. You can perform it while some other branch is checked out โ€” fancy-footer in our case.

Once the fast-forward merge is complete, the edge between master and sticky-header gets gray, which means that the latter has been merged.
master is now ahead of remote because of the commits from sticky-header. Since master hasn't diverged from its remote tracking branch, Push... does not require force.

You can now Slide Out the merged sticky-header branch. The remaining master and fancy-footer branches are now in sync.

Complete feature list

Please see the feature list for more specific feature description.

Build

Please see the development documentation for instructions on how to build this plugin on your own.

Issue reporting

If you see any bug or just would like to propose any new feature, feel free to create an issue.

When reporting a bug, it'd be very helpful for us if you could enable the IntelliJ logging on a DEBUG level, reproduce a bug and include the logs from IntelliJ in the issue.

Go to Help > Diagnostic Tools > Debug Log Settings and then paste the following line:

com.virtuslab

Then reproduce the bug and go to Help > Show Log in Files (Help > Show Log in Finder on macOS) to open the log file.

References

For additional background on what we believe are good practices take a look into our slides presentation. It explains our motivations and gives you an overview of main Git Machete objectives.

For more information about the plugin, see the teaser blog post and the complete feature list.

See also git-machete โ€” a CLI version of this plugin.

git-machete-intellij-plugin's People

Contributors

azdrojowa123 avatar beniamin-dolega avatar dcortezmeleth avatar dependabot[bot] avatar git-machete-bot avatar ishu-thakur avatar izabelalindner avatar lukaszkontowski avatar lukaszwawrzyk avatar maciejg604 avatar marconzet avatar micpiotrowski avatar mkondratek avatar pawellipski avatar vzmerr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

git-machete-intellij-plugin's Issues

Investigate usage of git4idea in backend

Usage of git4idea may bring many benefits (as some eventual operation are already refer to it).

Potentially depending on git4idea would give possibilities to handle the changing state of repository easier.

Set up code formatter to keep field annotations in the preceding line

  @Nonnull @Getter
  private static final RepositoryGraph nullRepositoryGraph = new RepositoryGraphBuilder().build();

is much more readable than

  @Nonnull @Getter private static final RepositoryGraph nullRepositoryGraph = new RepositoryGraphBuilder().build();

esp. if there's a bunch a fields declared one after another.

Repairing of SLF4J error

This error are printed out on stderr when JGit is initialized:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation

Reduce spacing between graph elements

After increasing spaces and adding the indents (#85) graph became too high.

Find and apply the solution to improve its layout in this aspect.

Suggested solution:
Modify the high of some (splitting and phantom?) graph elements` cells.

Consider making compile-time dependencies intransitive by default

For instance now intellijPlugin has a transitive dependency on gitCoreApi and branchRelationFileApi... but most likely, for the sake of low coupling, it should just have access to the interfaces of gitMacheteApi and not the interfaces deeper layers (of course it doesn't have the access to the implementations already, but that's not the issue here).

So, consider making the compile-time module dependencies intransitive by default if feasible.

Investigate pros and cons of var usage

and depending on the results of the investigation

  • use is more (especially refactor intellijPlugin module, that does not use vars)
    or
  • limit it usage to proper situations

Extract common Gradle dependencies (Guice, Lombok, junit) to a shared location

If possible, extract the entire dependencies { ... } block (ofc excluding references to other modules of the project) and maybe even plugins/sourceCompatibility/repositories. If that's not easily doable, at least extract the versions of external dependencies to a shared location for easy updating (btw e.g. junit got updated to 4.13 in the meantime)

Improve color handling in graph elements

SyncToParentStatus presence enables us to pick and distinguish colors specified for graph elements.

However, for some elements SyncToParentStatus field is confusing (in particular to any other than BranchElement).

The same applies to SyncToOriginStatus.

Coloring of graph elements needs a general refactoring.

Rename packages, classes and interfaces to more appropriate forms

com.virtuslab.branchrelationfile -> com.virtuslab.branchrelationfile.impl
com.virtuslab.gitcore.gitcoreapi -> com.virtuslab.gitcore.api
com.virtuslab.gitcore.gitcorejgit -> com.virtuslab.gitcore.impl
com.virtuslab.gitmachete.gitmacheteapi -> com.virtuslab.gitmachete.api
com.virtuslab.gitmachete.gitmachetejgit -> com.virtuslab.gitmachete.impl

JGit* -> GitCore*

Checkout branch from graph table

Motivation:
Switching branches with DvcsStatusWidget (down right corner), console git checkout or from version Control Log table is inconvenient (might enforce you to close Git Machete tab).

  1. First decide how the feature should be handled (double click, dropdown, some other way?).
  2. Add the possibility to perform branch checkout from Git Machete graph table.

Class that may be worth to have a look at: git4idea.branch.GitBranchWorker

Employ Vavr (or maybe rather Guava?) where reasonable

https://www.vavr.io/vavr-docs

Immutable collections FTW, I'd use them everywhere :all-the-things:

Also possibly Try<...> e.g. for things like result of parsing .git/machete and consider Option instead of Optional everywhere for better null handling (?)

To a lesser extent: Lazy, pattern matching

Btw1: read about Vavr's name origin/history if you haven't heard, it's pretty epic

Btw2: for me this lib literally looks like making constructs from Scala as closely reflected in Java as possible (they mention Scala in the docs a couple times)

Btw3: it's pronounced /หˆweษช.vษš/ like "waiver", lol

Custom annotations cause exception

Steps to reproduce:
create GitMacheteRepository with machete file containing custom annotation

Expected:
No exception. Annotations handled/ignored.

Actual:
org.eclipse.jgit.errors.RevisionSyntaxException: Invalid ref name

Ensure each PR bumps version in intellijPlugin/build.gradle

Add a script that ensures that the version has been version bumped (wrt. MINOR or PATCH - for pre-production versions 0.x.y that doesn't matter much, https://semver.org/) into CI pipeline. That would be super-useful to avoid confusion while beta-testing (nothing worse than two even slightly different versions of the same software... that nevertheless have the same version number).

Not sure if CircleCI gives an easy access to PR base branch from inside the pipeline... if the answer isn't immediately obvious, check env vars, git remote -v, git config -l for hints. Otherwise, it can be always compared to what's on origin/master (which is almost surely available from inside the pipeline).

Wire up static code analyzer to CI

Preferably a one that is fully configurable (as in, each specific check can be turned off/on, and if on, severity level can be chosen - warn/error).

This is intended to catch smells that aren't captured by Java compiler by default, like comparing an Optional instance to null.

Illegal reflective access on CI during gradle test

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/root/.gradle/caches/modules-2/files-2.1/com.google.inject/guice/4.2.2/6dacbe18e5eaa7f6c9c36db33b42e7985e94ce77/guice-4.2.2.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.