├── .gitignore
├── GITFLOW_VERSION.md
├── ISSUE_TEMPLATE.md
├── LICENSE.txt
├── README.md
├── build.gradle.kts
├── docs
├── img
│ ├── gitflow.png
│ ├── import_options.png
│ ├── import_project.png
│ └── run_configuration.png
└── project_setup.md
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── src
└── main
├── java
└── gitflow
│ ├── DefaultOptions.java
│ ├── GitInitLineHandler.java
│ ├── Gitflow.java
│ ├── GitflowBranchUtil.java
│ ├── GitflowBranchUtilManager.java
│ ├── GitflowComponent.java
│ ├── GitflowConfigUtil.java
│ ├── GitflowConfigurable.java
│ ├── GitflowImpl.java
│ ├── GitflowInitOptions.java
│ ├── GitflowMenu.java
│ ├── GitflowOptionsFactory.java
│ ├── GitflowState.java
│ ├── GitflowVersionTester.java
│ ├── IDEAUtils.java
│ ├── JSONUtils.java
│ ├── actions
│ ├── AbstractBranchAction.java
│ ├── AbstractPublishAction.java
│ ├── AbstractStartAction.java
│ ├── AbstractTrackAction.java
│ ├── FinishBugfixAction.java
│ ├── FinishFeatureAction.java
│ ├── FinishHotfixAction.java
│ ├── FinishReleaseAction.java
│ ├── GitflowAction.java
│ ├── GitflowActions.java
│ ├── GitflowErrorsListener.java
│ ├── GitflowLineHandler.java
│ ├── GitflowPopupGroup.java
│ ├── InitRepoAction.java
│ ├── OpenGitflowPopup.java
│ ├── PublishBugfixAction.java
│ ├── PublishFeatureAction.java
│ ├── PublishHotfixAction.java
│ ├── PublishReleaseAction.java
│ ├── ReInitRepoAction.java
│ ├── RepoActions.java
│ ├── StartBugfixAction.java
│ ├── StartFeatureAction.java
│ ├── StartHotfixAction.java
│ ├── StartReleaseAction.java
│ ├── TrackBugfixAction.java
│ ├── TrackFeatureAction.java
│ └── TrackReleaseAction.java
│ └── ui
│ ├── AbstractBranchStartDialog.form
│ ├── AbstractBranchStartDialog.java
│ ├── AbstractGitflowActionAckDialog.form
│ ├── AbstractGitflowActionAckDialog.java
│ ├── GitflowBranchChooseDialog.form
│ ├── GitflowBranchChooseDialog.java
│ ├── GitflowCloseTaskPanel.form
│ ├── GitflowCloseTaskPanel.java
│ ├── GitflowFinishActionAckDialog.java
│ ├── GitflowInitOptionsDialog.form
│ ├── GitflowInitOptionsDialog.java
│ ├── GitflowOpenTaskPanel.form
│ ├── GitflowOpenTaskPanel.java
│ ├── GitflowOptionsForm.form
│ ├── GitflowOptionsForm.java
│ ├── GitflowPublishActionAckDialog.java
│ ├── GitflowStartBugfixDialog.java
│ ├── GitflowStartFeatureDialog.java
│ ├── GitflowStartHotfixDialog.java
│ ├── GitflowStatusBarWidgetFactory.java
│ ├── GitflowTaskDialogPanelProvider.java
│ ├── GitflowWidget.java
│ ├── NotifyUtil.java
│ └── UnsupportedVersionWidgetPresentation.java
└── resources
└── META-INF
└── plugin.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 |
3 | ### Gradle template
4 | .gradle
5 | /build/
6 |
7 | # Ignore Gradle GUI config
8 | gradle-app.setting
9 |
10 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
11 | !gradle-wrapper.jar
12 |
13 | # Cache of project
14 | .gradletasknamecache
15 |
16 | # # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
17 | # gradle/wrapper/gradle-wrapper.properties
18 |
19 | ### Java template
20 | # Compiled class file
21 | *.class
22 |
23 | # Log file
24 | *.log
25 |
26 | # BlueJ files
27 | *.ctxt
28 |
29 | # Mobile Tools for Java (J2ME)
30 | .mtj.tmp/
31 |
32 | # Package Files #
33 | *.jar
34 | *.war
35 | *.nar
36 | *.ear
37 | *.zip
38 | *.tar.gz
39 | *.rar
40 |
41 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
42 | hs_err_pid*
43 |
44 | ### JetBrains template
45 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
46 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
47 |
48 | # User-specific stuff
49 | .idea/**/workspace.xml
50 | .idea/**/tasks.xml
51 | .idea/**/dictionaries
52 | .idea/**/shelf
53 | .idea/**/hotswap_agent.xml
54 | .idea/**/misc.xml
55 | .idea/**/checkstyle-idea.xml
56 |
57 | # Sensitive or high-churn files
58 | .idea/**/dataSources/
59 | .idea/**/dataSources.ids
60 | .idea/**/dataSources.local.xml
61 | .idea/**/sqlDataSources.xml
62 | .idea/**/dynamic.xml
63 | .idea/**/uiDesigner.xml
64 | .idea/**/dbnavigator.xml
65 |
66 | .idea/**/gradle.xml
67 | .idea/**/libraries
68 | .idea/**/modules.xml
69 | **/*.iml
70 | .idea/libraries/**/*.xml
71 |
72 | # CMake
73 | cmake-build-debug/
74 | cmake-build-release/
75 |
76 | # Mongo Explorer plugin
77 | .idea/**/mongoSettings.xml
78 |
79 | # File-based project format
80 | *.iws
81 |
82 | # IntelliJ
83 | out/
84 |
85 | # mpeltonen/sbt-idea plugin
86 | .idea_modules/
87 |
88 | # JIRA plugin
89 | atlassian-ide-plugin.xml
90 |
91 | # Cursive Clojure plugin
92 | .idea/replstate.xml
93 |
94 | # Crashlytics plugin (for Android Studio and IntelliJ)
95 | com_crashlytics_export_strings.xml
96 | crashlytics.properties
97 | crashlytics-build.properties
98 | fabric.properties
99 |
100 | # Editor-based Rest Client
101 | .idea/httpRequests
102 |
103 | # GitEye project file
104 | /.project
105 |
106 | .idea
--------------------------------------------------------------------------------
/GITFLOW_VERSION.md:
--------------------------------------------------------------------------------
1 | The plugin requires that you have gitflow installed, specifically the [AVH edition](https://github.com/petervanderdoes/gitflow). This is because the [Vanilla Git Flow](https://github.com/nvie/gitflow) hasn't been maintained in years
2 |
3 | **How to check Git Flow version**
4 |
5 | run `git flow version`
6 |
7 | If it says `0.4.1` then you have the wrong version. You will have to uninstall it and then refer to [AVH edition](https://github.com/petervanderdoes/gitflow) docs for installation.
8 |
9 |
10 | **How to uninstall wrong version on OSX**
11 |
12 | If installed via `brew` then run `brew uninstall git-flow`
13 |
14 |
15 | **Mac/Linux users:**
16 |
17 | If you're running into issues like getting
18 | `Gitflow is not installed`
19 | or
20 | `git: 'flow' is not a git command. See 'git --help'.`
21 |
22 | Please be sure to check out [this thread](https://github.com/OpherV/gitflow4idea/issues/7)
23 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | * **I'm submitting a ...**
2 | - [ ] bug report
3 | - [ ] feature request
4 | - [ ] puppy => You're not submitting a puppy. I already have one and he's [adorable](https://twitter.com/Opherv/status/974341249099542528)
5 |
6 |
7 | * **What is the current behavior?**
8 |
9 |
10 |
11 | * **Is this a bug? Sorry about that. If so give me explicit details how to reproduce:**
12 |
13 | 1. Open IntelliJ
14 | 2. ???
15 | 3. Profit
16 |
17 | * **What is the expected behavior?**
18 |
19 |
20 |
21 | * **What is the motivation / use case for changing the behavior?**
22 |
23 | * **Please tell me about your environment:**
24 |
25 | - Gitflow4idea version: *find in IntelliJ settings plugins*
26 | - Gitflow version: run in terminal `>git flow version`
27 |
28 | - *IntelliJ Help -> about > click copy icon and paste here. Should look like this:*
29 | ~~~~
30 | IntelliJ IDEA 2018.1.1 EAP (Community Edition)
31 | Build #IC-181.4445.4, built on March 29, 2018
32 | JRE: 1.8.0_152-release-1136-b27 x86_64
33 | JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
34 | ~~~~
35 |
36 |
37 |
38 | * **Other information** (e.g. detailed explanation, stacktrace, related issues, suggestions how to fix, links for me to have context words of praises, pictures of puppies (again with the puppy??) )
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Git Flow Integration Plus for Intellij
2 |
3 | ### Available @ [JetBrains Plugins Repository][1]
4 |
5 |
6 | An intelliJ plugin providing a UI layer for git-flow, which in itself is a collection of Git extensions to provide high-level repository operations for Vincent [Driessen's branching model](http://nvie.com/git-model).
7 |
8 | 
9 |
10 |
11 |
12 | ## Getting started
13 |
14 | For the best introduction to get started with `git flow`, please read Jeff Kreeftmeijer's blog post:
15 |
16 | [http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/](http://jeffkreeftmeijer.com/2010/why-arent-you-using-git-flow/)
17 |
18 | Or have a look at this [cheat sheet](http://danielkummer.github.io/git-flow-cheatsheet/) by Daniel Kummer:
19 |
20 | Huge shoutout [to Kirill Likhodedov](https://github.com/klikh), who wrote much of the original git4idea plugin, without which this plugin could not exist
21 |
22 | ## Online Installation
23 |
24 | The plugin is available via the IntelliJ plugin manager. Just search for "Git Flow Integration Plus" to get the latest version!
25 |
26 | **The plugin requires that you have gitflow installed, specifically the [AVH edition](https://github.com/petervanderdoes/gitflow). This is because the [Vanilla Git Flow](https://github.com/nvie/gitflow) hasn't been maintained in years.** See this page [for details](https://github.com/RubinCarter/gitflow4idea-fix/blob/develop/GITFLOW_VERSION.md)
27 |
28 | ## Offline Installation
29 | download path: https://github.com/RubinCarter/gitflow4idea-fix/releases
30 |
31 | Installation document:https://www.jetbrains.com/help/idea/managing-plugins.html#install_plugin_from_disk
32 |
33 | **The plugin requires that you have gitflow installed, specifically the [AVH edition](https://github.com/petervanderdoes/gitflow). This is because the [Vanilla Git Flow](https://github.com/nvie/gitflow) hasn't been maintained in years.** See this page [for details](https://github.com/RubinCarter/gitflow4idea-fix/blob/develop/GITFLOW_VERSION.md)
34 |
35 | ## Caveats
36 |
37 | While the plugin is operational and contains all basic functions (init/feature/release/hotfix), it may contains bugs. With your help I'll be able to find and zap them all.
38 |
39 | ## Helping out
40 |
41 | This project is under active development.
42 | If you encounter any bug or an issue, I encourage you to add the them to the [Issues list](https://github.com/RubinCarter/gitflow4idea-fix/issues) on Github.
43 | Feedback and suggestions are also very welcome.
44 |
45 | ## License
46 |
47 | This plugin is under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html).
48 | Copyright 2013-2020, Opher Vishnia.
49 |
50 | ## Who and why
51 |
52 | This plugin was created by [Opher Vishnia](http://www.opherv.com), after I couldn't find any similar implementation.
53 | I saw this [suggestion page](http://youtrack.jetbrains.com/issue/IDEA-65491) on the JetBrains site has more than 220 likes and 80 comments, and decided to take up the gauntlet :)
54 |
55 | This plugin is forked from original https://github.com/OpherV/gitflow4idea .
56 |
57 |
58 |
59 | [1]: https://plugins.jetbrains.com/plugin/18320-git-flow-integration-plus
60 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("java")
3 | id("org.jetbrains.intellij") version "1.14.2"
4 | }
5 |
6 | repositories {
7 | mavenLocal()
8 | mavenCentral()
9 | }
10 |
11 | group = "gitflow4idea-plus"
12 | version = "0.8.0"
13 |
14 | java {
15 | sourceCompatibility = JavaVersion.VERSION_17
16 | targetCompatibility = JavaVersion.VERSION_17
17 | }
18 |
19 | dependencies {
20 | testImplementation("junit:junit:4.13.2")
21 | }
22 |
23 | intellij {
24 | version.set("2023.1")
25 | plugins.set(listOf("Git4Idea", "tasks"))
26 | updateSinceUntilBuild.set(false)
27 | }
28 |
29 | tasks {
30 | patchPluginXml {
31 | pluginId.set("Gitflow-Fix")
32 | pluginDescription.set("""
33 |
Git Flow Integration for Intellij
34 | An intelliJ plugin providing a UI layer for git-flow, which in itself is a collection of Git extensions to provide high-level repository operations for Vincent Driessen's branching model
35 | """)
36 | version.set("${project.version}")
37 | sinceBuild.set("231.8109.175")
38 | changeNotes.set("""
39 | Changelog for 0.7.13
40 |
41 | - Fix "(class com.intellij.openapi.project.impl.ProjectImpl) has already been disposed" #29
42 |
43 |
44 | Changelog for 0.7.11
45 |
46 | - Fix "Access is allowed from event dispatch thread only" #17 #21 #19
47 |
48 |
49 | Changelog for 0.7.10
50 |
51 | - Fix "Error during startup" #4
52 |
53 |
54 | Changelog for 0.7.9
55 |
56 | - Support for 2022.1 build
57 |
58 |
59 | Changelog for 0.7.8
60 |
61 | - Support for 2021.3 build
62 |
63 |
64 | Changelog for 0.7.7
65 |
66 | - Fix issue with "Unsupported gitflow version" message presented at startup #328 #329
67 | - Support for 2021.2 build
68 |
69 |
70 | Changelog for 0.7.6
71 |
72 | - Fix "Error using shortcuts" #322
73 | - fix Finishing BugFix throws stacktrace #320
74 | - Support for 2021.1 build
75 |
76 |
77 | Changelog for 0.7.5
78 |
79 | - PluginException: Icon cannot be found in 'AllIcons.Vcs.CheckOut' #314 (@tumb1er)
80 | - Support for 2020.3 build
81 |
82 |
83 | Changelog for 0.7.4
84 |
85 | - Fix deprecations #298 (@fabmars)
86 | - Support for 2020.2 build
87 |
88 |
89 | Changelog for 0.7.3
90 |
91 | - Implemented sorting and filtering of track branch dialog #290 (@mmopitz)
92 | - Fix Version 0.7.2 causes that Active Tool Windows only is showed in one project if you have several open #301 (@tumb1er)
93 | - Fix Unsupported Git Flow version Fix #302 (@opherv)
94 | - Fix init settings shown in UI are misleading (do not match default) #283 (@opherv)
95 |
96 |
97 | Changelog for 0.7.2
98 |
99 | - Support for Idea build 200 #276 (@fabmars, @tumb1er )
100 | - Fix Icon cannot be found in 'AllIcons.Vcs.' #286 (@fabmars)
101 | - Fix finish release error (Mac OS) #273 (@opherv)
102 | - Breaking 'Search Everywhere' dialog window for projects without git #265 (@opherv)
103 |
104 |
105 | Changelog for 0.7.1
106 |
107 | - Support for Idea build 193 #259 (@opherv)
108 | - Check that the user has AVH version of git flow installed, show dialog otherwise #253 (@opherv)
109 | - Add safety which should help fix #249 - Init repo failed #259 (@opherv)
110 | - Fix Memory leak of ProjectImpl and GitRepositoryImpl after projet is closed #255 (@opherv)
111 | - Add icons to actions #232 (@opherv)
112 |
113 |
114 | Changelog for 0.7.0
115 |
116 | - Fix NPE when clicking Gitflow menu #245 (@opherv)
117 | - Fix "Init gitflow" doesn't update widget #247 (@opherv)
118 | - Fix Wrong message when finishing a feature #144 (@opherv)
119 | - Feature: Re-init gitflow (access from VCS>Git>Gitflow>Advanced menu) #50 (@bmwsedee/@opherv)
120 | - "Feature": Don't show branch select combo on new Hotfix (@opherv)
121 |
122 |
123 | Changelog for 0.6.9
124 |
125 | - Support for Idea build 192 #241 (@opherv)
126 | - Feature: No Fast-forward option is not working #225 (@opherv)
127 | - Hotfix: option -k to keep branch after performing finish #199 (@opherv)
128 | - Exceptions #243 #235 #323 #223 (@bmwsedee)
129 |
130 |
131 | Changelog for 0.6.8
132 |
133 | - Support for Idea build 191 #221 (@ottnorml)
134 | - Fix performance issues in plugin #195 (@bmwsedee)
135 |
136 |
137 | Note - if you see 'no gitflow' in the status bar you will need to re-init using git flow init -f
138 | """)
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/docs/img/gitflow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RubinCarter/gitflow4idea-plus/30a4425426a5ce4bbdbca62eef42a984d3bf8509/docs/img/gitflow.png
--------------------------------------------------------------------------------
/docs/img/import_options.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RubinCarter/gitflow4idea-plus/30a4425426a5ce4bbdbca62eef42a984d3bf8509/docs/img/import_options.png
--------------------------------------------------------------------------------
/docs/img/import_project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RubinCarter/gitflow4idea-plus/30a4425426a5ce4bbdbca62eef42a984d3bf8509/docs/img/import_project.png
--------------------------------------------------------------------------------
/docs/img/run_configuration.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RubinCarter/gitflow4idea-plus/30a4425426a5ce4bbdbca62eef42a984d3bf8509/docs/img/run_configuration.png
--------------------------------------------------------------------------------
/docs/project_setup.md:
--------------------------------------------------------------------------------
1 | # Setup Guide
2 | This document shall assist you in setting up the development project in IntelliJ IDEA. There are two ways of setting up the project:
3 | 1. Gradle Setup
4 | 2. "Classic" Setup
5 |
6 | ## Gradle Setup
7 |
8 | ### Prerequisites
9 | - The environment variable `JAVA_HOME` is set to a valid Java environment.
10 | - The *Gradle* plugin is enable in IntelliJ IDEA.
11 |
12 | ### Setup Steps
13 | 1. Fork the original repository and checkout the fork.
14 | 2. Import the project into IntelliJ IDEA.
15 | 3. Choose *"Import from external model" > Gradle*.
16 | 4. Set the following options in the import dialog:
17 | - *Use Auto Import*
18 | - *Create directories for empty content roots automatically*
19 | - *Use default gradle wrapper (recommended)*
20 |
21 | 
22 | 
23 |
24 | ### Run Configuration
25 | Add a new run configuration of type *Gradle* with the following settings:
26 | - Set the current project as *Gradle project*
27 | - In *Tasks* enter `runIde`.
28 |
29 | This should give you a basic run configuration which will start a new IntelliJ instance with the plugin deployed.
30 |
31 | 
32 |
33 | ## "Classic" Setup
34 |
35 | ### 1. Make sure the plugin development plugin is enabled
36 |
37 | Start IDEA, go to *Settings -> Plugins* and make sure that `Plugin DevKit` is installed and enabled.
38 | If it's not, install it now.
39 |
40 | ### 2. Clone the project from GitHub
41 |
42 | Typically you check out your fork of the project on GitHub here.
43 |
44 | ### 3. Import the project into IDEA
45 |
46 | Select the *Import Project* option (e.g. by pressing shift twice and entering "import project")
47 | and navigate to the cloned repository directory when prompted.
48 |
49 | #### Model
50 |
51 | Chose "From existing sources" when prompted for a model.
52 |
53 | #### SDK Setup
54 |
55 | If you dont have a plugin SDK yet, click `+` to add an SDK and select *IntelliJ Platform Plugin SDK*
56 |
57 | 1. Navigate to your IDEA installation and select the installation directory.
58 | 2. Afterwards select a JDK when prompted
59 |
60 | Select your plugin SDK as the one to use.
61 |
62 | #### Other
63 |
64 | The remaining options can be left at default
65 |
66 | ### 4. Change the project type
67 |
68 | Open the projects iml file (it should be named `gitflow4idea.iml` by default) and replace its contents with this:
69 |
70 | ```xml
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | ```
83 |
84 | Then close and reopen the project to apply the changes.
85 |
86 | ### 5. Add git4idea dependency
87 |
88 | 1. Open the module settings and navigate to *Modules -> gitflow4idea (or your project name here)* and select the *Dependencies* tab.
89 | 2. Click add -> "JARs or directories" and add `git4idea.jar`.
90 | This can be found in your IDEA installation directory under `plugins/git4idea/lib`.
91 | 3. Change the scope of the added JAR to **provided**.
92 |
93 | ### 6. Create a run configuration
94 |
95 | Go to Run/Debug configurations and create a new configuration of the type `Plugin`. Under "Use classpath of module" select the project (`gitflow4idea` by default).
96 | Click run. A new IDEA instance should start with the plugin running.
97 |
98 | And that's it. You can now make changes to the source and run them.
99 |
100 | ### Notes & hints
101 |
102 | #### Language level
103 |
104 | This project is written to target Java 8, so make sure to set the project language level appropriately
105 | to avoid accidentally using newer features. You can do so in the module settings under "modules -> gitflow4idea -> sources -> Language level".
106 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RubinCarter/gitflow4idea-plus/30a4425426a5ce4bbdbca62eef42a984d3bf8509/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
4 | networkTimeout=10000
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | # This is normally unused
84 | # shellcheck disable=SC2034
85 | APP_BASE_NAME=${0##*/}
86 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147 | # shellcheck disable=SC3045
148 | MAX_FD=$( ulimit -H -n ) ||
149 | warn "Could not query maximum file descriptor limit"
150 | esac
151 | case $MAX_FD in #(
152 | '' | soft) :;; #(
153 | *)
154 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155 | # shellcheck disable=SC3045
156 | ulimit -n "$MAX_FD" ||
157 | warn "Could not set maximum file descriptor limit to $MAX_FD"
158 | esac
159 | fi
160 |
161 | # Collect all arguments for the java command, stacking in reverse order:
162 | # * args from the command line
163 | # * the main class name
164 | # * -classpath
165 | # * -D...appname settings
166 | # * --module-path (only if needed)
167 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
168 |
169 | # For Cygwin or MSYS, switch paths to Windows format before running java
170 | if "$cygwin" || "$msys" ; then
171 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
172 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
173 |
174 | JAVACMD=$( cygpath --unix "$JAVACMD" )
175 |
176 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
177 | for arg do
178 | if
179 | case $arg in #(
180 | -*) false ;; # don't mess with options #(
181 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
182 | [ -e "$t" ] ;; #(
183 | *) false ;;
184 | esac
185 | then
186 | arg=$( cygpath --path --ignore --mixed "$arg" )
187 | fi
188 | # Roll the args list around exactly as many times as the number of
189 | # args, so each arg winds up back in the position where it started, but
190 | # possibly modified.
191 | #
192 | # NB: a `for` loop captures its iteration list before it begins, so
193 | # changing the positional parameters here affects neither the number of
194 | # iterations, nor the values presented in `arg`.
195 | shift # remove old arg
196 | set -- "$@" "$arg" # push replacement arg
197 | done
198 | fi
199 |
200 | # Collect all arguments for the java command;
201 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
202 | # shell script including quotes and variable substitutions, so put them in
203 | # double quotes to make sure that they get re-expanded; and
204 | # * put everything else in single quotes, so that it's not re-expanded.
205 |
206 | set -- \
207 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
208 | -classpath "$CLASSPATH" \
209 | org.gradle.wrapper.GradleWrapperMain \
210 | "$@"
211 |
212 | # Stop when "xargs" is not available.
213 | if ! command -v xargs >/dev/null 2>&1
214 | then
215 | die "xargs is not available"
216 | fi
217 |
218 | # Use "xargs" to parse quoted args.
219 | #
220 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
221 | #
222 | # In Bash we could simply go:
223 | #
224 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
225 | # set -- "${ARGS[@]}" "$@"
226 | #
227 | # but POSIX shell has neither arrays nor command substitution, so instead we
228 | # post-process each arg (as a line of input to sed) to backslash-escape any
229 | # character that might be a shell metacharacter, then use eval to reverse
230 | # that process (while maintaining the separation between arguments), and wrap
231 | # the whole thing up as a single "set" statement.
232 | #
233 | # This will of course break if any of these variables contains a newline or
234 | # an unmatched quote.
235 | #
236 |
237 | eval "set -- $(
238 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
239 | xargs -n1 |
240 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
241 | tr '\n' ' '
242 | )" '"$@"'
243 |
244 | exec "$JAVACMD" "$@"
245 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/DefaultOptions.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import java.util.HashMap;
4 | import java.util.Map;
5 |
6 | public class DefaultOptions {
7 | private static final Map options;
8 | static
9 | {
10 | options = new HashMap();
11 | options.put("RELEASE_customTagCommitMessage", "Tagging version %name%");
12 | options.put("HOTFIX_customHotfixCommitMessage", "Tagging hotfix %name%");
13 | }
14 |
15 | public static String getOption(String optionId){
16 | return options.get(optionId);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/GitInitLineHandler.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import com.intellij.execution.ExecutionException;
4 | import com.intellij.execution.configurations.GeneralCommandLine;
5 | import com.intellij.execution.process.OSProcessHandler;
6 | import com.intellij.execution.process.ProcessAdapter;
7 | import com.intellij.execution.process.ProcessEvent;
8 | import com.intellij.openapi.project.Project;
9 | import com.intellij.openapi.util.Key;
10 | import com.intellij.openapi.util.registry.Registry;
11 | import com.intellij.openapi.vfs.VirtualFile;
12 | import git4idea.commands.GitCommand;
13 | import git4idea.commands.GitLineHandler;
14 | import git4idea.commands.GitTextHandler;
15 | import git4idea.util.GitVcsConsoleWriter;
16 | import org.jetbrains.annotations.NotNull;
17 | import org.jetbrains.annotations.Nullable;
18 |
19 | import java.io.BufferedWriter;
20 | import java.io.IOException;
21 | import java.io.OutputStreamWriter;
22 |
23 |
24 | public class GitInitLineHandler extends GitLineHandler {
25 | private final GitVcsConsoleWriter consoleWriter;
26 |
27 | private BufferedWriter writer;
28 | GitflowInitOptions _initOptions;
29 |
30 | public GitInitLineHandler(GitflowInitOptions initOptions,
31 | @NotNull Project project, @NotNull VirtualFile vcsRoot,
32 | @NotNull GitCommand command) {
33 | super(project, vcsRoot, command);
34 | consoleWriter = GitVcsConsoleWriter.getInstance(project);
35 | _initOptions = initOptions;
36 | }
37 |
38 | @Override
39 | protected OSProcessHandler createProcess(@NotNull GeneralCommandLine commandLine) throws ExecutionException {
40 | MyOSProcessHandler process = new MyOSProcessHandler(commandLine, this.myWithMediator && Registry.is("git.execute.with.mediator"));
41 | process.addProcessListener(new ProcessAdapter() {
42 | @Override
43 | public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
44 | String s = event.getText();
45 | GitInitLineHandler.this.onTextAvailable(s);
46 | }
47 | });
48 | return process;
49 | }
50 |
51 | public void onTextAvailable(String s) {
52 | try {
53 | if (s.contains("name for production releases")) {
54 | consoleWriter.showCommandLine(_initOptions.getProductionBranch());
55 |
56 | writer.write(_initOptions.getProductionBranch());
57 | writer.write("\n");
58 | writer.flush();
59 | }
60 |
61 | if (s.contains("name for \"next release\"")) {
62 | consoleWriter.showCommandLine(_initOptions.getDevelopmentBranch());
63 |
64 | writer.write(_initOptions.getDevelopmentBranch());
65 | writer.write("\n");
66 | writer.flush();
67 | }
68 |
69 | if (s.contains("Feature branches")) {
70 | consoleWriter.showCommandLine(_initOptions.getFeaturePrefix());
71 |
72 | writer.write(_initOptions.getFeaturePrefix());
73 | writer.write("\n");
74 | writer.flush();
75 | }
76 | if (s.contains("Bugfix branches")) {
77 | consoleWriter.showCommandLine(_initOptions.getBugfixPrefix());
78 |
79 | writer.write(_initOptions.getBugfixPrefix());
80 | writer.write("\n");
81 | writer.flush();
82 | }
83 | if (s.contains("Release branches")) {
84 | consoleWriter.showCommandLine(_initOptions.getReleasePrefix());
85 |
86 | writer.write(_initOptions.getReleasePrefix());
87 | writer.write("\n");
88 | writer.flush();
89 | }
90 | if (s.contains("Hotfix branches")) {
91 | consoleWriter.showCommandLine(_initOptions.getHotfixPrefix());
92 |
93 | writer.write(_initOptions.getHotfixPrefix());
94 | writer.write("\n");
95 | writer.flush();
96 | }
97 | if (s.contains("Support branches")) {
98 | consoleWriter.showCommandLine(_initOptions.getSupportPrefix());
99 |
100 | writer.write(_initOptions.getSupportPrefix());
101 | writer.write("\n");
102 | writer.flush();
103 | }
104 | if (s.contains("Version tag")) {
105 | consoleWriter.showCommandLine(_initOptions.getVersionPrefix());
106 |
107 | writer.write(_initOptions.getVersionPrefix());
108 | writer.write("\n");
109 | writer.flush();
110 | }
111 | if (s.contains("Hooks and filters")) {
112 | writer.write("\n");
113 | writer.flush();
114 | }
115 |
116 |
117 | } catch (IOException e) {
118 | e.printStackTrace();
119 | }
120 | }
121 |
122 | @Nullable
123 | @Override
124 | protected Process startProcess() throws ExecutionException {
125 | Process p = super.startProcess();
126 | writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));
127 | return p;
128 | }
129 |
130 | @Override
131 | protected void processTerminated(int exitCode) {
132 | super.processTerminated(exitCode);
133 | }
134 |
135 | static class MyOSProcessHandler extends GitTextHandler.MyOSProcessHandler {
136 | MyOSProcessHandler(@NotNull GeneralCommandLine commandLine,
137 | boolean withMediator) throws ExecutionException {
138 | super(commandLine, withMediator);
139 | }
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/Gitflow.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import com.intellij.openapi.project.Project;
4 | import git4idea.commands.Git;
5 | import git4idea.commands.GitCommandResult;
6 | import git4idea.commands.GitLineHandlerListener;
7 | import git4idea.repo.GitRemote;
8 | import git4idea.repo.GitRepository;
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | /**
13 | * @author Opher Vishnia / opherv.com / opherv@gmail.com
14 | */
15 | public interface Gitflow extends Git {
16 |
17 | GitCommandResult initRepo(@NotNull GitRepository repository,
18 | GitflowInitOptions initOptions,
19 | @Nullable GitLineHandlerListener... listeners);
20 |
21 | GitCommandResult reInitRepo(@NotNull GitRepository repository,
22 | GitflowInitOptions initOptions,
23 | @Nullable GitLineHandlerListener... listeners);
24 |
25 |
26 | // feature
27 |
28 | GitCommandResult startFeature(@NotNull GitRepository repository,
29 | @NotNull String featureName,
30 | @Nullable String baseBranch,
31 | @Nullable GitLineHandlerListener... listeners);
32 |
33 | GitCommandResult finishFeature(@NotNull GitRepository repository,
34 | @NotNull String featureName,
35 | @Nullable GitLineHandlerListener... listeners);
36 |
37 | GitCommandResult publishFeature(@NotNull GitRepository repository,
38 | @NotNull String featureName,
39 | @Nullable GitLineHandlerListener... listeners);
40 |
41 | GitCommandResult pullFeature(@NotNull GitRepository repository,
42 | @NotNull String featureName,
43 | @NotNull GitRemote remote,
44 | @Nullable GitLineHandlerListener... listeners);
45 |
46 | GitCommandResult trackFeature(@NotNull GitRepository repository,
47 | @NotNull String featureName,
48 | @NotNull GitRemote remote,
49 | @Nullable GitLineHandlerListener... listeners);
50 |
51 | //release
52 |
53 | GitCommandResult startRelease(@NotNull GitRepository repository,
54 | @NotNull String releaseName,
55 | @Nullable GitLineHandlerListener... listeners);
56 |
57 |
58 | GitCommandResult finishRelease(@NotNull GitRepository repository,
59 | @NotNull String releaseName,
60 | @NotNull String tagMessage,
61 | @Nullable GitLineHandlerListener... listeners);
62 |
63 |
64 | GitCommandResult publishRelease(@NotNull GitRepository repository,
65 | @NotNull String releaseName,
66 | @Nullable GitLineHandlerListener... listeners);
67 |
68 | GitCommandResult trackRelease(@NotNull GitRepository repository,
69 | @NotNull String releaseName,
70 | @Nullable GitLineHandlerListener... listeners);
71 |
72 | //hotfix
73 |
74 | GitCommandResult startHotfix(@NotNull GitRepository repository,
75 | @NotNull String hotfixName,
76 | @Nullable String baseBranch,
77 | @Nullable GitLineHandlerListener... listeners);
78 |
79 | GitCommandResult finishHotfix(@NotNull GitRepository repository,
80 | @NotNull String hotfixName,
81 | @NotNull String tagMessage,
82 | @Nullable GitLineHandlerListener... listeners);
83 |
84 | GitCommandResult publishHotfix(@NotNull GitRepository repository,
85 | @NotNull String hotfixName,
86 | @Nullable GitLineHandlerListener... listeners);
87 |
88 | // Bugfix
89 |
90 | GitCommandResult startBugfix(@NotNull GitRepository repository,
91 | @NotNull String bugfixName,
92 | @Nullable String baseBranch,
93 | @Nullable GitLineHandlerListener... listeners);
94 |
95 | GitCommandResult finishBugfix(@NotNull GitRepository repository,
96 | @NotNull String bugfixName,
97 | @Nullable GitLineHandlerListener... listeners);
98 |
99 | GitCommandResult publishBugfix(@NotNull GitRepository repository,
100 | @NotNull String bugfixName,
101 | @Nullable GitLineHandlerListener... listeners);
102 |
103 | GitCommandResult pullBugfix(@NotNull GitRepository repository,
104 | @NotNull String bugfixName,
105 | @NotNull GitRemote remote,
106 | @Nullable GitLineHandlerListener... listeners);
107 |
108 | GitCommandResult trackBugfix(@NotNull GitRepository repository,
109 | @NotNull String bugfixName,
110 | @NotNull GitRemote remote,
111 | @Nullable GitLineHandlerListener... listeners);
112 |
113 | GitCommandResult version(@NotNull Project project, GitLineHandlerListener... listeners);
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/GitflowBranchUtilManager.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import com.intellij.openapi.project.Project;
4 | import com.intellij.openapi.util.Disposer;
5 | import git4idea.GitUtil;
6 | import git4idea.repo.GitRepository;
7 |
8 | import java.util.HashMap;
9 | import java.util.Iterator;
10 | import java.util.List;
11 |
12 | /**
13 | * This class maps repos to their corresponding branch utils
14 | * Note that the static class is used across projects
15 | */
16 |
17 | public class GitflowBranchUtilManager {
18 | private static HashMap repoBranchUtilMap;
19 |
20 | static public GitflowBranchUtil getBranchUtil(GitRepository repo){
21 | if (repo != null && repoBranchUtilMap != null) {
22 | return repoBranchUtilMap.get(repo.getPresentableUrl());
23 | } else {
24 | return null;
25 | }
26 | }
27 |
28 | static public void setupBranchUtil(Project project, GitRepository repo){
29 | GitflowBranchUtil gitflowBranchUtil = new GitflowBranchUtil(project, repo);
30 | repoBranchUtilMap.put(repo.getPresentableUrl(), gitflowBranchUtil);
31 | // clean up
32 | Disposer.register(repo, () -> repoBranchUtilMap.remove(repo));
33 | }
34 |
35 | /**
36 | * Repopulates the branchUtils for each repo
37 | * @param proj
38 | */
39 | static public void update(Project proj){
40 | if (repoBranchUtilMap == null){
41 | repoBranchUtilMap = new HashMap();
42 | }
43 |
44 | List gitRepositories = GitUtil.getRepositoryManager(proj).getRepositories();
45 | for (GitRepository repo : gitRepositories) {
46 | GitflowBranchUtilManager.setupBranchUtil(proj, repo);
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/GitflowComponent.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import com.intellij.openapi.Disposable;
4 | import com.intellij.openapi.project.Project;
5 | import com.intellij.openapi.vcs.ProjectLevelVcsManager;
6 | import com.intellij.openapi.vcs.VcsListener;
7 | import com.intellij.openapi.vcs.VcsRoot;
8 | import com.intellij.openapi.wm.StatusBar;
9 | import com.intellij.openapi.wm.StatusBarWidget;
10 | import com.intellij.openapi.wm.WindowManager;
11 | import com.intellij.util.messages.MessageBus;
12 | import git4idea.GitVcs;
13 | import gitflow.ui.GitflowWidget;
14 |
15 |
16 | /**
17 | * @author Opher Vishnia / opherv.com / opherv@gmail.com
18 | * One instance per project
19 | */
20 | public class GitflowComponent implements VcsListener, Disposable {
21 | Project myProject;
22 | GitflowWidget myGitflowWidget;
23 | MessageBus messageBus;
24 |
25 | public GitflowComponent(Project project) {
26 | myProject = project;
27 | messageBus = myProject.getMessageBus();
28 | messageBus.connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this);
29 | // Seems the event triggering this component happens after the directory mapping change
30 | directoryMappingChanged();
31 | }
32 |
33 | @Override
34 | public void dispose() {
35 | // TODO: insert component disposal logic here
36 | }
37 |
38 | @Override
39 | public void directoryMappingChanged() {
40 | VcsRoot[] vcsRoots = ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots();
41 | if (vcsRoots.length > 0 && vcsRoots[0].getVcs() instanceof GitVcs) {
42 |
43 | StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
44 | GitflowWidget widget = (GitflowWidget) statusBar.getWidget(GitflowWidget.class.getName());
45 | if (widget != null) {
46 | widget.updateAsync();
47 | } else {
48 | throw new NullPointerException("widget");
49 | }
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/GitflowConfigUtil.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import java.util.concurrent.ExecutionException;
4 | import java.util.concurrent.Future;
5 |
6 | import com.intellij.openapi.application.ApplicationManager;
7 | import com.intellij.openapi.project.Project;
8 | import com.intellij.openapi.util.Disposer;
9 | import com.intellij.openapi.vcs.VcsException;
10 | import com.intellij.openapi.vfs.VirtualFile;
11 | import git4idea.config.GitConfigUtil;
12 | import git4idea.repo.GitRepository;
13 | import gitflow.ui.NotifyUtil;
14 | import org.jetbrains.annotations.NotNull;
15 |
16 | import java.util.HashMap;
17 | import java.util.Map;
18 |
19 | /**
20 | *
21 | *
22 | * @author Opher Vishnia / opherv.com / opherv@gmail.com
23 | */
24 |
25 | public class GitflowConfigUtil {
26 |
27 | public static final String BRANCH_MASTER = "gitflow.branch.master";
28 | public static final String BRANCH_DEVELOP = "gitflow.branch.develop";
29 | public static final String PREFIX_FEATURE = "gitflow.prefix.feature";
30 | public static final String PREFIX_RELEASE = "gitflow.prefix.release";
31 | public static final String PREFIX_HOTFIX = "gitflow.prefix.hotfix";
32 | public static final String PREFIX_BUGFIX = "gitflow.prefix.bugfix";
33 | public static final String PREFIX_SUPPORT = "gitflow.prefix.support";
34 | public static final String PREFIX_VERSIONTAG = "gitflow.prefix.versiontag";
35 |
36 | private static Map> gitflowConfigUtilMap = new HashMap>();
37 |
38 | Project project;
39 | GitRepository repo;
40 | public String masterBranch;
41 | public String developBranch;
42 | public String featurePrefix;
43 | public String releasePrefix;
44 | public String hotfixPrefix;
45 | public String bugfixPrefix;
46 | public String supportPrefix;
47 | public String versiontagPrefix;
48 |
49 | public static GitflowConfigUtil getInstance(@NotNull Project project_, @NotNull GitRepository repo_)
50 | {
51 | GitflowConfigUtil instance;
52 | if (gitflowConfigUtilMap.containsKey(project_) && gitflowConfigUtilMap.get(project_).containsKey(repo_.getPresentableUrl())) {
53 | instance = gitflowConfigUtilMap.get(project_).get(repo_.getPresentableUrl());
54 | } else {
55 | Map innerMap = new HashMap();
56 | instance = new GitflowConfigUtil(project_, repo_);
57 |
58 | gitflowConfigUtilMap.put(project_, innerMap);
59 | innerMap.put(repo_.getPresentableUrl(), instance);
60 |
61 | //cleanup
62 | Disposer.register(repo_, () -> innerMap.remove(repo_));
63 | Disposer.register(project_, () -> gitflowConfigUtilMap.remove(project_));
64 | }
65 |
66 | return instance;
67 | }
68 |
69 | GitflowConfigUtil(Project project_, GitRepository repo_){
70 | project = project_;
71 | repo = repo_;
72 |
73 | update();
74 | }
75 |
76 | public void update(){
77 | VirtualFile root = repo.getRoot();
78 |
79 | try{
80 | Future> f = ApplicationManager.getApplication().executeOnPooledThread(() -> {
81 | try {
82 | masterBranch = GitConfigUtil.getValue(project, root, BRANCH_MASTER);
83 | developBranch = GitConfigUtil.getValue(project, root, BRANCH_DEVELOP);
84 | featurePrefix = GitConfigUtil.getValue(project, root, PREFIX_FEATURE);
85 | releasePrefix = GitConfigUtil.getValue(project, root, PREFIX_RELEASE);
86 | hotfixPrefix = GitConfigUtil.getValue(project, root, PREFIX_HOTFIX);
87 | bugfixPrefix = GitConfigUtil.getValue(project, root, PREFIX_BUGFIX);
88 | supportPrefix = GitConfigUtil.getValue(project, root, PREFIX_SUPPORT);
89 | versiontagPrefix = GitConfigUtil.getValue(project, root, PREFIX_VERSIONTAG);
90 | } catch (VcsException e) {
91 | NotifyUtil.notifyError(project, "Config error", e);
92 | }
93 | });
94 | f.get();
95 |
96 | } catch (InterruptedException e) {
97 | e.printStackTrace();
98 | } catch (ExecutionException e) {
99 | e.printStackTrace();
100 | }
101 | }
102 |
103 |
104 | public String getFeatureNameFromBranch(String branchName){
105 | return branchName.substring(branchName.indexOf(featurePrefix)+featurePrefix.length(),branchName.length());
106 | }
107 |
108 | public String getReleaseNameFromBranch(String branchName){
109 | return branchName.substring(branchName.indexOf(releasePrefix) + releasePrefix.length(), branchName.length());
110 | }
111 |
112 | public String getHotfixNameFromBranch(String branchName){
113 | return branchName.substring(branchName.indexOf(hotfixPrefix) + hotfixPrefix.length(), branchName.length());
114 | }
115 |
116 | public String getBugfixNameFromBranch(String branchName){
117 | return branchName.substring(branchName.indexOf(bugfixPrefix)+bugfixPrefix.length(),branchName.length());
118 | }
119 |
120 | public String getRemoteNameFromBranch(String branchName){
121 | return branchName.substring(0,branchName.indexOf("/"));
122 | }
123 |
124 | public void setMasterBranch(String branchName)
125 | {
126 | masterBranch = branchName;
127 | VirtualFile root = repo.getRoot();
128 | try {
129 | GitConfigUtil.setValue(project, root, BRANCH_MASTER, branchName);
130 | } catch (VcsException e) {
131 | NotifyUtil.notifyError(project, "Config error", e);
132 | }
133 | }
134 |
135 | public void setDevelopBranch(String branchName) {
136 | developBranch = branchName;
137 | VirtualFile root = repo.getRoot();
138 | try {
139 | GitConfigUtil.setValue(project, root, BRANCH_DEVELOP, branchName);
140 | } catch (VcsException e) {
141 | NotifyUtil.notifyError(project, "Config error", e);
142 | }
143 | }
144 |
145 | public void setReleasePrefix(String prefix) {
146 | releasePrefix = prefix;
147 | VirtualFile root = repo.getRoot();
148 |
149 | try {
150 | GitConfigUtil.setValue(project, root, PREFIX_RELEASE, prefix);
151 | } catch (VcsException e) {
152 | NotifyUtil.notifyError(project, "Config error", e);
153 | }
154 | }
155 |
156 | public void setFeaturePrefix(String prefix) {
157 | featurePrefix = prefix;
158 | VirtualFile root = repo.getRoot();
159 |
160 | try {
161 | GitConfigUtil.setValue(project, root, PREFIX_FEATURE, prefix);
162 | } catch (VcsException e) {
163 | NotifyUtil.notifyError(project, "Config error", e);
164 | }
165 | }
166 |
167 | public void setHotfixPrefix(String prefix) {
168 | hotfixPrefix = prefix;
169 | VirtualFile root = repo.getRoot();
170 |
171 | try {
172 | GitConfigUtil.setValue(project, root, PREFIX_HOTFIX, prefix);
173 | } catch (VcsException e) {
174 | NotifyUtil.notifyError(project, "Config error", e);
175 | }
176 | }
177 |
178 | public void setBugfixPrefix(String prefix) {
179 | bugfixPrefix = prefix;
180 | VirtualFile root = repo.getRoot();
181 |
182 | try {
183 | GitConfigUtil.setValue(project, root, PREFIX_BUGFIX, prefix);
184 | } catch (VcsException e) {
185 | NotifyUtil.notifyError(project, "Config error", e);
186 | }
187 | }
188 |
189 | public void setSupportPrefix(String prefix) {
190 | supportPrefix = prefix;
191 | VirtualFile root = repo.getRoot();
192 |
193 | try {
194 | GitConfigUtil.setValue(project, root, PREFIX_SUPPORT, prefix);
195 | } catch (VcsException e) {
196 | NotifyUtil.notifyError(project, "Config error", e);
197 | }
198 | }
199 |
200 | public void setVersionPrefix(String prefix) {
201 | versiontagPrefix = prefix;
202 | VirtualFile root = repo.getRoot();
203 |
204 | try {
205 | GitConfigUtil.setValue(project, root, PREFIX_VERSIONTAG, prefix);
206 | } catch (VcsException e) {
207 | NotifyUtil.notifyError(project, "Config error", e);
208 | }
209 | }
210 |
211 | // this still reads from config because it always runs from an action and never from the EDT
212 | public String getBaseBranch(String branchName){
213 |
214 | VirtualFile root = repo.getRoot();
215 |
216 | String baseBranch=null;
217 | try{
218 | baseBranch = GitConfigUtil.getValue(project, root, "gitflow.branch."+branchName+".base");
219 | }
220 | catch (VcsException e) {
221 | NotifyUtil.notifyError(project, "Config error", e);
222 | }
223 |
224 | return baseBranch;
225 | }
226 | }
227 |
--------------------------------------------------------------------------------
/src/main/java/gitflow/GitflowConfigurable.java:
--------------------------------------------------------------------------------
1 | package gitflow;
2 |
3 | import com.intellij.ide.util.PropertiesComponent;
4 | import com.intellij.openapi.options.Configurable;
5 | import com.intellij.openapi.options.ConfigurationException;
6 | import com.intellij.openapi.project.Project;
7 | import gitflow.ui.GitflowOptionsForm;
8 | import org.jetbrains.annotations.Nullable;
9 |
10 | import javax.swing.*;
11 | import java.util.ArrayList;
12 | import java.util.HashMap;
13 | import java.util.Map;
14 |
15 | /**
16 | * @author Andreas Vogler (Andreas.Vogler@geneon.de)
17 | * @author Opher Vishnia (opherv@gmail.com)
18 | */
19 | public class GitflowConfigurable implements Configurable {
20 |
21 | Project project;
22 | GitflowOptionsForm gitflowOptionsForm;
23 | PropertiesComponent propertiesComponent;
24 | Map, ArrayList