├── .gitignore ├── README.md └── magit-gitflow.el /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | magit-gitflow 2 | ============= 3 | 4 | [GitFlow][gitflow] plugin for [magit.el][magit] 5 | 6 | 7 | Setup 8 | ----- 9 | 10 | Install [gitflow] and put the following in your `.emacs`: 11 | 12 | ```lisp 13 | ;;; C-f in the magit status buffer invokes the magit-gitflow popup. If you 14 | ;;; would like to use a different key, set the magit-gitflow-popup-key variable 15 | ;;; before loading magit-gitflow 16 | ;; (setq magit-gitflow-popup-key "C-n") 17 | 18 | (require 'magit-gitflow) 19 | (add-hook 'magit-mode-hook 'turn-on-magit-gitflow) 20 | ``` 21 | 22 | Press C-f in magit status buffer and you will be presented with 23 | the gitflow popup menu. 24 | 25 | All gitflow commands are also accessible through the Magit/Extensions/GitFlow 26 | pop-down menu. 27 | 28 | 29 | [gitflow]: https://github.com/petervanderdoes/gitflow 30 | [magit]: https://github.com/magit/magit/tree/master 31 | -------------------------------------------------------------------------------- /magit-gitflow.el: -------------------------------------------------------------------------------- 1 | ;;; magit-gitflow.el --- gitflow extension for magit -*- lexical-binding: t; -*- 2 | 3 | ;; Copyright (C) 2014, 2015, 2016, 2017 Jan Tatarik 4 | 5 | ;; Author: Jan Tatarik 6 | ;; Keywords: vc tools 7 | ;; URL: https://github.com/jtatarik/magit-gitflow 8 | ;; Package: magit-gitflow 9 | ;; Package-Requires: ((magit "2.1.0") (magit-popup "2.2.0")) 10 | 11 | ;; This program is free software; you can redistribute it and/or modify 12 | ;; it under the terms of the GNU General Public License as published by 13 | ;; the Free Software Foundation, either version 3 of the License, or 14 | ;; (at your option) any later version. 15 | 16 | ;; This program is distributed in the hope that it will be useful, 17 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | ;; GNU General Public License for more details. 20 | 21 | ;; You should have received a copy of the GNU General Public License 22 | ;; along with this program. If not, see . 23 | 24 | ;;; Commentary: 25 | ;; 26 | ;; Gitflow plugin for Magit. 27 | ;; 28 | ;; (require 'magit-gitflow) 29 | ;; (add-hook 'magit-mode-hook 'turn-on-magit-gitflow) 30 | ;; 31 | ;; C-f in magit status buffer will invoke the gitflow popup. 32 | ;; 33 | 34 | ;;; Code: 35 | 36 | (require 'magit) 37 | (require 'magit-popup) 38 | (require 'magit-process) 39 | (require 'subr-x) 40 | 41 | (defvar magit-gitflow-mode-lighter " GitFlow") 42 | 43 | (defvar magit-gitflow-popup-key "C-f") 44 | 45 | (defvar magit-gitflow-mode-map 46 | (let ((map (make-sparse-keymap))) 47 | (define-key map (kbd magit-gitflow-popup-key) 'magit-gitflow-popup) 48 | map)) 49 | 50 | (define-minor-mode magit-gitflow-mode 51 | "GitFlow support for Magit." 52 | :lighter magit-gitflow-mode-lighter 53 | :keymap magit-gitflow-mode-map 54 | (or (derived-mode-p 'magit-mode) 55 | (user-error "This mode only makes sense with magit"))) 56 | 57 | ;;;###autoload 58 | (defun turn-on-magit-gitflow () 59 | "Unconditionally turn on `magit-gitflow-mode'." 60 | (magit-gitflow-mode 1)) 61 | 62 | (easy-menu-define magit-gitflow-extension-menu nil 63 | "GitFlow extension menu" 64 | '("GitFlow" :visible magit-gitflow-mode 65 | 66 | ("Initialization/setup" 67 | ["Initialize defaults" magit-gitflow-init 68 | :help "Initialize GitFlow in the current repository"] 69 | ["Set feature prefix" magit-gitflow-init-feature] 70 | ["Set release prefix" magit-gitflow-init-release] 71 | ["Set hotfix prefix" magit-gitflow-init-hotfix] 72 | ["Set support prefix" magit-gitflow-init-support] 73 | ["Set versiontag prefix" magit-gitflow-init-versiontag]) 74 | 75 | ("Feature" 76 | ["Start" magit-gitflow-feature-start-popup] 77 | ["Finish" magit-gitflow-feature-finish-popup] 78 | ["Publish" magit-gitflow-feature-publish] 79 | ["Delete" magit-gitflow-feature-delete-popup] 80 | ["Track" magit-gitflow-feature-track] 81 | ["Diff" magit-gitflow-feature-diff] 82 | ["Rebase" magit-gitflow-feature-rebase-popup]) 83 | 84 | ("Bugfix" 85 | ["Start" magit-gitflow-bugfix-start-popup] 86 | ["Finish" magit-gitflow-bugfix-finish-popup] 87 | ["Publish" magit-gitflow-bugfix-publish] 88 | ["Delete" magit-gitflow-bugfix-delete-popup] 89 | ["Track" magit-gitflow-bugfix-track] 90 | ["Diff" magit-gitflow-bugfix-diff] 91 | ["Rebase" magit-gitflow-bugfix-rebase-popup]) 92 | 93 | ("Release" 94 | ["Start" magit-gitflow-release-start-popup] 95 | ["Finish" magit-gitflow-release-finish-popup] 96 | ["Publish" magit-gitflow-release-publish] 97 | ["Delete" magit-gitflow-release-delete-popup] 98 | ["Track" magit-gitflow-release-track]) 99 | 100 | ("Hotfix" 101 | ["Start" magit-gitflow-hotfix-start-popup] 102 | ["Finish" magit-gitflow-hotfix-finish-popup] 103 | ["Publish" magit-gitflow-hotfix-publish] 104 | ["Delete" magit-gitflow-hotfix-delete-popup]) 105 | 106 | ["Support" magit-gitflow-support-start-popup])) 107 | 108 | 109 | (easy-menu-add-item 'magit-mode-menu '("Extensions") 110 | magit-gitflow-extension-menu) 111 | 112 | 113 | ;;; Commands 114 | 115 | (magit-define-popup magit-gitflow-popup 116 | "Popup console for GitFlow commands." 117 | 'magit-popups 118 | :actions '((?i "Init" magit-gitflow-init-popup) 119 | (?f "Feature" magit-gitflow-feature-popup) 120 | (?b "Bugfix" magit-gitflow-bugfix-popup) 121 | (?r "Release" magit-gitflow-release-popup) 122 | (?h "Hotfix" magit-gitflow-hotfix-popup) 123 | (?s "Support" magit-gitflow-support-start-popup))) 124 | 125 | ;; 126 | ;; git flow INIT 127 | ;; 128 | 129 | (magit-define-popup magit-gitflow-init-popup 130 | "Popup console for GitFlow 'init' command." 131 | 'magit-gitflow-popup 132 | :actions '((?i "Initialize defaults" magit-gitflow-init) 133 | (?f "Feature prefix" magit-gitflow-init-feature) 134 | (?b "Bugfix prefix" magit-gitflow-init-bugfix) 135 | (?r "Release prefix" magit-gitflow-init-release) 136 | (?h "Hotfix prefix" magit-gitflow-init-hotfix) 137 | (?s "Support prefix" magit-gitflow-init-support) 138 | (?v "Version tag prefix" magit-gitflow-init-versiontag)) 139 | :switches '((?f "Force reinitialization" "--force"))) 140 | 141 | ;; 142 | ;; git flow FEATURE 143 | ;; 144 | 145 | (magit-define-popup magit-gitflow-feature-popup 146 | "Popup console for GitFlow 'feature' command." 147 | 'magit-gitflow-popup 148 | :actions '((?s "Start" magit-gitflow-feature-start-popup) 149 | (?f "Finish" magit-gitflow-feature-finish-popup) 150 | (?p "Publish" magit-gitflow-feature-publish) 151 | (?d "Delete" magit-gitflow-feature-delete-popup) 152 | (?t "Track" magit-gitflow-feature-track) 153 | (?D "Diff" magit-gitflow-feature-diff) 154 | (?r "Rebase" magit-gitflow-feature-rebase-popup))) 155 | 156 | (magit-define-popup magit-gitflow-feature-start-popup 157 | "Popup console for GitFlow 'feature start' command." 158 | 'magit-gitflow-feature-popup 159 | :actions '((?s "Start" magit-gitflow-feature-start)) 160 | :switches '((?F "Fetch" "--fetch"))) 161 | 162 | (magit-define-popup magit-gitflow-feature-finish-popup 163 | "Popup console for GitFlow 'feature finish' command." 164 | 'magit-gitflow-feature-popup 165 | :actions '((?f "Finish" magit-gitflow-feature-finish)) 166 | :switches '((?F "Fetch" "--fetch") 167 | (?r "Rebase" "--rebase") 168 | (?p "Preserve merges" "--preserve-merges") 169 | (?k "Keep branch" "--keep") 170 | (?R "Keep remote branch" "--keepremote") 171 | (?L "Keep local branch" "--keeplocal") 172 | (?D "Force delete branch" "--force_delete") 173 | (?S "Squash" "--squash") 174 | (?n "No fast-forward" "--no-ff"))) 175 | 176 | (magit-define-popup magit-gitflow-feature-delete-popup 177 | "Popup console for GitFlow 'feature delete' command." 178 | 'magit-gitflow-feature-popup 179 | :actions '((?d "Delete" magit-gitflow-feature-delete)) 180 | :switches '((?f "Force" "--force") 181 | (?r "Delete remote" "--remote"))) 182 | 183 | 184 | (magit-define-popup magit-gitflow-feature-rebase-popup 185 | "Popup console for GitFlow 'feature rebase' command." 186 | 'magit-gitflow-feature-popup 187 | :actions '((?r "Rebase" magit-gitflow-feature-rebase)) 188 | :switches '((?i "Interactive" "--interactive") 189 | (?p "Preserve merges" "--preserve-merges"))) 190 | 191 | 192 | ;; 193 | ;; git flow BUGFIX 194 | ;; 195 | 196 | (magit-define-popup magit-gitflow-bugfix-popup 197 | "Popup console for GitFlow 'bugfix' command." 198 | 'magit-gitflow-popup 199 | :actions '((?s "Start" magit-gitflow-bugfix-start-popup) 200 | (?f "Finish" magit-gitflow-bugfix-finish-popup) 201 | (?p "Publish" magit-gitflow-bugfix-publish) 202 | (?d "Delete" magit-gitflow-bugfix-delete-popup) 203 | (?t "Track" magit-gitflow-bugfix-track) 204 | (?D "Diff" magit-gitflow-bugfix-diff) 205 | (?r "Rebase" magit-gitflow-bugfix-rebase-popup))) 206 | 207 | (magit-define-popup magit-gitflow-bugfix-start-popup 208 | "Popup console for GitFlow 'bugfix start' command." 209 | 'magit-gitflow-bugfix-popup 210 | :actions '((?s "Start" magit-gitflow-bugfix-start)) 211 | :switches '((?F "Fetch" "--fetch"))) 212 | 213 | (magit-define-popup magit-gitflow-bugfix-finish-popup 214 | "Popup console for GitFlow 'bugfix finish' command." 215 | 'magit-gitflow-bugfix-popup 216 | :actions '((?f "Finish" magit-gitflow-bugfix-finish)) 217 | :switches '((?F "Fetch" "--fetch") 218 | (?r "Rebase" "--rebase") 219 | (?p "Preserve merges" "--preserve-merges") 220 | (?k "Keep branch" "--keep") 221 | (?R "Keep remote branch" "--keepremote") 222 | (?L "Keep local branch" "--keeplocal") 223 | (?D "Force delete branch" "--force_delete") 224 | (?S "Squash" "--squash") 225 | (?n "No fast-forward" "--no-ff"))) 226 | 227 | (magit-define-popup magit-gitflow-bugfix-delete-popup 228 | "Popup console for GitFlow 'bugfix delete' command." 229 | 'magit-gitflow-bugfix-popup 230 | :actions '((?d "Delete" magit-gitflow-bugfix-delete)) 231 | :switches '((?f "Force" "--force") 232 | (?r "Delete remote" "--remote"))) 233 | 234 | 235 | (magit-define-popup magit-gitflow-bugfix-rebase-popup 236 | "Popup console for GitFlow 'bugfix rebase' command." 237 | 'magit-gitflow-bugfix-popup 238 | :actions '((?r "Rebase" magit-gitflow-bugfix-rebase)) 239 | :switches '((?i "Interactive" "--interactive") 240 | (?p "Preserve merges" "--preserve-merges"))) 241 | 242 | 243 | ;; 244 | ;; git flow RELEASE 245 | ;; 246 | 247 | (magit-define-popup magit-gitflow-release-popup 248 | "Popup console for GitFlow 'release' command." 249 | 'magit-gitflow-popup 250 | :actions '((?s "Start" magit-gitflow-release-start) 251 | (?f "Finish" magit-gitflow-release-finish-popup) 252 | (?p "Publish" magit-gitflow-release-publish) 253 | (?d "Delete" magit-gitflow-release-delete-popup) 254 | (?t "Track" magit-gitflow-release-track))) 255 | 256 | (magit-define-popup magit-gitflow-release-start-popup 257 | "Popup console for GitFlow 'release start' command." 258 | 'magit-gitflow-release-popup 259 | :actions '((?s "Start" magit-gitflow-release-start)) 260 | :switches '((?F "Fetch" "--fetch"))) 261 | 262 | (magit-define-popup magit-gitflow-release-finish-popup 263 | "Popup console for GitFlow 'release finish' command." 264 | 'magit-gitflow-release-popup 265 | :actions '((?f "Finish" magit-gitflow-release-finish)) 266 | :options '((?u "Signing key" "--signingkey=" read-file-name) 267 | (?m "Tag message" "--message=" read-string) 268 | (?f "Tag message file" "--messagefile=" read-file-name)) 269 | :switches '((?F "Fetch before finish" "--fetch") 270 | (?s "Sign" "--sign") 271 | (?p "Push after finish" "--push") 272 | (?k "Keep branch" "--keep") 273 | (?R "Keep remote branch" "--keepremote") 274 | (?L "Keep local branch" "--keeplocal") 275 | (?D "Force delete branch" "--force_delete") 276 | (?n "Don't tag" "--notag") 277 | (?b "Don't back-merge master" "--nobackmerge") 278 | (?S "Squash" "--squash"))) 279 | 280 | (magit-define-popup magit-gitflow-release-delete-popup 281 | "Popup console for GitFlow 'release delete' command." 282 | 'magit-gitflow-release-popup 283 | :actions '((?d "Delete" magit-gitflow-release-delete)) 284 | :switches '((?f "Force" "--force") 285 | (?r "Delete remote branch" "--remote"))) 286 | 287 | ;; 288 | ;; git flow HOTFIX 289 | ;; 290 | 291 | (magit-define-popup magit-gitflow-hotfix-popup 292 | "Popup console for GitFlow 'hotfix' command." 293 | 'magit-gitflow-popup 294 | :actions '((?s "Start" magit-gitflow-hotfix-start-popup) 295 | (?f "Finish" magit-gitflow-hotfix-finish-popup) 296 | (?p "Publish" magit-gitflow-hotfix-publish) 297 | (?d "Delete" magit-gitflow-hotfix-delete-popup))) 298 | 299 | (magit-define-popup magit-gitflow-hotfix-start-popup 300 | "Popup console for GitFlow 'hotfix start' command." 301 | 'magit-gitflow-hotfix-popup 302 | :actions '((?s "Start" magit-gitflow-hotfix-start)) 303 | :switches '((?F "Fetch" "--fetch"))) 304 | 305 | (magit-define-popup magit-gitflow-hotfix-finish-popup 306 | "Popup console for GitFlow 'hotfix finish' command." 307 | 'magit-gitflow-hotfix-popup 308 | :actions '((?f "Finish" magit-gitflow-hotfix-finish)) 309 | :options '((?u "Signing key" "--signingkey=" read-file-name) 310 | (?m "Tag message" "--message=" read-string) 311 | (?f "Tag message file" "--messagefile=" read-file-name)) 312 | :switches '((?F "Fetch before finish" "--fetch") 313 | (?s "Sign" "--sign") 314 | (?p "Push after finish" "--push") 315 | (?k "Keep branch" "--keep") 316 | (?R "Keep remote branch" "--keepremote") 317 | (?L "Keep local branch" "--keeplocal") 318 | (?D "Force delete branch" "--force_delete") 319 | (?n "Don't tag" "--notag") 320 | (?b "Don't back-merge master" "--nobackmerge"))) 321 | 322 | (magit-define-popup magit-gitflow-hotfix-delete-popup 323 | "Popup console for GitFlow 'hotfix delete' command." 324 | 'magit-gitflow-hotfix-popup 325 | :actions '((?d "Delete" magit-gitflow-hotfix-delete)) 326 | :switches '((?f "Force" "--force") 327 | (?r "Delete remote branch" "--remote"))) 328 | 329 | 330 | ;; 331 | ;; git flow SUPPORT 332 | ;; 333 | 334 | (magit-define-popup magit-gitflow-support-start-popup 335 | "Popup console for GitFlow 'support start' command." 336 | 'magit-gitflow-popup 337 | :actions '((?s "Start" magit-gitflow-support-start)) 338 | :switches '((?F "Fetch" "--fetch"))) 339 | 340 | 341 | 342 | ;;; Utilities 343 | 344 | (defun magit-run-gitflow (&rest args) 345 | "Execute 'git flow' with given ARGS." 346 | (apply #'magit-run-git "flow" args)) 347 | 348 | (defun magit-gitflow-get-config-key (key) 349 | "Read gitconfig value for gitflow KEY." 350 | (or (magit-get (format "gitflow.%s" key)) 351 | (user-error "Not a gitflow-enabled repo, please run 'git flow init' first"))) 352 | 353 | (defmacro define-magit-gitflow-cmd (cmd) 354 | "Define function to execute 'git flow CMD' commands. 355 | 356 | The new function will be called magit-run-gitflow-CMD." 357 | (let ((defun-name (intern (format "magit-run-gitflow-%s" cmd))) 358 | (version-prompt (format "%s name" (upcase-initials cmd))) 359 | (config-key (format "prefix.%s" cmd))) 360 | 361 | `(defun ,defun-name (args) 362 | (let* ((prefix (magit-gitflow-get-config-key ,config-key)) 363 | (current-branch (magit-get-current-branch)) 364 | (current-feature (if (string-prefix-p prefix current-branch) 365 | (substring current-branch (length prefix)) 366 | ""))) 367 | 368 | (magit-run-gitflow ,cmd args 369 | magit-current-popup-args 370 | (string-remove-prefix 371 | prefix 372 | (magit-completing-read ,version-prompt 373 | (magit-list-refnames "refs/heads") 374 | (lambda (ref) (string-prefix-p prefix ref)) 375 | t 376 | current-branch))))))) 377 | 378 | (define-magit-gitflow-cmd "feature") 379 | (define-magit-gitflow-cmd "bugfix") 380 | (define-magit-gitflow-cmd "release") 381 | (define-magit-gitflow-cmd "hotfix") 382 | 383 | 384 | (defmacro define-magit-gitflow-branch-cmd (branch cmd) 385 | "Define function that executes 'git flow BRANCH CMD' commands. 386 | 387 | The new function will be called magit-gitflow-BRANCH-CMD." 388 | 389 | (let ((branch-execute (intern (format "magit-run-gitflow-%s" branch))) 390 | (defun-name (intern (format "magit-gitflow-%s-%s" branch cmd)))) 391 | 392 | `(defun ,defun-name () 393 | (interactive) 394 | (,branch-execute ,cmd)))) 395 | 396 | 397 | ;; 398 | ;; git flow INIT 399 | ;; 400 | (defun magit-gitflow-init () 401 | (interactive) 402 | (magit-run-gitflow "init" "-d" magit-current-popup-args)) 403 | 404 | (defun magit-gitflow-init-prefix (key prompt) 405 | (let* ((config-key (format "gitflow.prefix.%s" key)) 406 | (default-prefix (or (magit-get config-key) ""))) 407 | (magit-set 408 | (read-string prompt default-prefix) config-key))) 409 | 410 | (defun magit-gitflow-init-feature () 411 | (interactive) 412 | (magit-gitflow-init-prefix "feature" "Feature branch prefix: ")) 413 | 414 | (defun magit-gitflow-init-bugfix () 415 | (interactive) 416 | (magit-gitflow-init-prefix "bugfix" "Bugfix branch prefix: ")) 417 | 418 | (defun magit-gitflow-init-release () 419 | (interactive) 420 | (magit-gitflow-init-prefix "release" "Release branch prefix: ")) 421 | 422 | (defun magit-gitflow-init-hotfix () 423 | (interactive) 424 | (magit-gitflow-init-prefix "hotfix" "Hotfix branch prefix: ")) 425 | 426 | (defun magit-gitflow-init-support () 427 | (interactive) 428 | (magit-gitflow-init-prefix "support" "Support branch prefix: ")) 429 | 430 | (defun magit-gitflow-init-versiontag () 431 | (interactive) 432 | (magit-gitflow-init-prefix "versiontag" "Version tag prefix: ")) 433 | 434 | 435 | ;; 436 | ;; git flow FEATURE 437 | ;; 438 | (defun magit-gitflow-feature-start (name) 439 | (interactive "sFeature name: ") 440 | (magit-run-gitflow "feature" "start" magit-current-popup-args name)) 441 | 442 | (define-magit-gitflow-branch-cmd "feature" "finish") 443 | (define-magit-gitflow-branch-cmd "feature" "publish") 444 | (define-magit-gitflow-branch-cmd "feature" "delete") 445 | 446 | (defun magit-gitflow-feature-rebase () 447 | (interactive) 448 | (let* ((prefix (magit-gitflow-get-config-key "prefix.feature")) 449 | (current-branch (magit-get-current-branch)) 450 | (args (append '("feature" "rebase") magit-current-popup-args (list (string-remove-prefix prefix current-branch))))) 451 | 452 | (when (string-prefix-p prefix current-branch) 453 | (magit-run-git-with-editor "flow" args)))) 454 | 455 | (defun magit-gitflow-feature-diff () 456 | (interactive) 457 | (let* ((prefix (magit-gitflow-get-config-key "prefix.feature")) 458 | (current-branch (magit-get-current-branch)) 459 | (base (magit-get (format "gitflow.branch.%s.base" current-branch)))) 460 | 461 | (when (and (string-prefix-p prefix current-branch) base) 462 | (magit-diff base current-branch)))) 463 | 464 | (defun magit-gitflow-feature-track () 465 | (interactive) 466 | (let ((prefix (magit-gitflow-get-config-key "prefix.feature"))) 467 | (magit-run-gitflow "feature" "track" 468 | (string-remove-prefix prefix (magit-read-remote-branch "Feature" "origin"))))) 469 | 470 | 471 | ;; 472 | ;; git flow BUGFIX 473 | ;; 474 | (defun magit-gitflow-bugfix-start (name) 475 | (interactive "sBugfix name: ") 476 | (magit-run-gitflow "bugfix" "start" magit-current-popup-args name)) 477 | 478 | (define-magit-gitflow-branch-cmd "bugfix" "finish") 479 | (define-magit-gitflow-branch-cmd "bugfix" "publish") 480 | (define-magit-gitflow-branch-cmd "bugfix" "delete") 481 | 482 | (defun magit-gitflow-bugfix-rebase () 483 | (interactive) 484 | (let* ((prefix (magit-gitflow-get-config-key "prefix.bugfix")) 485 | (current-branch (magit-get-current-branch)) 486 | (args (append '("bugfix" "rebase") magit-current-popup-args (list (string-remove-prefix prefix current-branch))))) 487 | 488 | (when (string-prefix-p prefix current-branch) 489 | (magit-run-git-with-editor "flow" args)))) 490 | 491 | (defun magit-gitflow-bugfix-diff () 492 | (interactive) 493 | (let* ((prefix (magit-gitflow-get-config-key "prefix.bugfix")) 494 | (current-branch (magit-get-current-branch)) 495 | (base (magit-get (format "gitflow.branch.%s.base" current-branch)))) 496 | 497 | (when (and (string-prefix-p prefix current-branch) base) 498 | (magit-diff base current-branch)))) 499 | 500 | (defun magit-gitflow-bugfix-track () 501 | (interactive) 502 | (let ((prefix (magit-gitflow-get-config-key "prefix.bugfix"))) 503 | (magit-run-gitflow "bugfix" "track" 504 | (string-remove-prefix prefix (magit-read-remote-branch "Bugfix" "origin"))))) 505 | 506 | ;; 507 | ;; git flow RELEASE 508 | ;; 509 | (defun magit-gitflow-release-start (version) 510 | (interactive "sRelease name: ") 511 | (magit-run-gitflow "release" "start" magit-current-popup-args version)) 512 | 513 | (defun magit-gitflow-release-finish () 514 | (interactive) 515 | (let* ((prefix (magit-gitflow-get-config-key "prefix.release")) 516 | (current-branch (magit-get-current-branch)) 517 | (current-release (if (string-prefix-p prefix current-branch) 518 | (substring current-branch (length prefix)) 519 | "")) 520 | (args (append '("release" "finish") magit-current-popup-args (list (read-string "Release name: " current-release))))) 521 | (magit-run-git-with-editor "flow" args))) 522 | 523 | (define-magit-gitflow-branch-cmd "release" "publish") 524 | (define-magit-gitflow-branch-cmd "release" "delete") 525 | 526 | (defun magit-gitflow-release-track () 527 | (interactive) 528 | (let ((prefix (magit-gitflow-get-config-key "prefix.release"))) 529 | (magit-run-gitflow "release" "track" 530 | (string-remove-prefix prefix (magit-read-remote-branch "Release" "origin"))))) 531 | 532 | 533 | ;; 534 | ;; git flow HOTFIX 535 | ;; 536 | (defun magit-gitflow-hotfix-start (version) 537 | (interactive "sHotfix name: ") 538 | (magit-run-gitflow "hotfix" "start" magit-current-popup-args version)) 539 | 540 | (defun magit-gitflow-hotfix-finish () 541 | (interactive) 542 | (let* ((prefix (magit-gitflow-get-config-key "prefix.hotfix")) 543 | (current-branch (magit-get-current-branch)) 544 | (current-hotfix (if (string-prefix-p prefix current-branch) 545 | (substring current-branch (length prefix)) 546 | "")) 547 | (args (append '("hotfix" "finish") magit-current-popup-args (list (read-string "Hotfix name: " current-hotfix))))) 548 | (magit-run-git-with-editor "flow" args))) 549 | 550 | (define-magit-gitflow-branch-cmd "hotfix" "publish") 551 | (define-magit-gitflow-branch-cmd "hotfix" "delete") 552 | 553 | 554 | ;; 555 | ;; git flow SUPPORT 556 | ;; 557 | (defun magit-gitflow-support-start () 558 | (interactive) 559 | (magit-run-gitflow "support" "start" magit-current-popup-args 560 | (read-string "Support branch name: ") 561 | (magit-read-local-branch-or-ref "Base"))) 562 | 563 | (provide 'magit-gitflow) 564 | ;;; magit-gitflow.el ends here 565 | --------------------------------------------------------------------------------