Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added git redmine command to create new branch

  • Loading branch information...
commit fcca331a3df32ce1c9d66bae90fdaf113dc2927d 1 parent 889afb9
@diasjorge authored
View
1  .gitignore
@@ -2,3 +2,4 @@ pkg/*
*.gem
.bundle
.rvmrc
+/tmp/aruba/*
View
9 bin/git-redmine
@@ -0,0 +1,9 @@
+#!/usr/bin/env ruby
+
+require 'pathname'
+lib = Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path
+$LOAD_PATH.unshift lib.to_s
+
+require 'redmine-cli/git'
+
+Redmine::Cli::Git.start
View
2  bin/redmine
@@ -4,6 +4,6 @@ require 'pathname'
lib = Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path
$LOAD_PATH.unshift lib.to_s
-require 'redmine-cli'
+require 'redmine-cli/cli'
Redmine::Cli::CLI.start
View
1  features/install.feature
@@ -15,6 +15,7 @@ Feature: Install configuration file
url: "http://example.com"
username: "user"
password: "pass"
+ default_project_id: 1
user_mappings:
"admin": 1
status_mappings:
View
4 lib/redmine-cli.rb
@@ -1,5 +1,7 @@
require 'thor'
require 'active_resource'
require 'redmine-cli/issue'
-require 'redmine-cli/cli'
require 'redmine-cli/generators/install'
+require 'redmine-cli/cli'
+require 'redmine-cli/git'
+
View
4 lib/redmine-cli/cli.rb
@@ -1,3 +1,7 @@
+require 'thor'
+require 'redmine-cli/issue'
+require 'redmine-cli/generators/install'
+
module Redmine
module Cli
class CLI < Thor
View
3  lib/redmine-cli/generators/.redmine
@@ -1,6 +1,7 @@
url: "<%= url %>"
username: "<%= username %>"
password: "<%= password %>"
+default_project_id: 1
user_mappings:
"admin": 1
status_mappings:
@@ -9,4 +10,4 @@ status_mappings:
"resolved": 3
"feedback": 4
"closed": 5
- "rejected": 6
+ "rejected": 6
View
19 lib/redmine-cli/git.rb
@@ -0,0 +1,19 @@
+require 'thor'
+require 'redmine-cli/issue'
+
+module Redmine
+ module Cli
+ class Git < Thor
+
+ desc "new TICKET", "Generate branch from ticket's information"
+ def new(ticket)
+ issue = Issue.find(ticket)
+ subject = issue.subject.gsub(/[^a-z0-9\-]+/i, "-").gsub(/-{1,}/,'-').gsub(/-$|^-/, '').downcase
+ `git checkout -b #{ticket}-#{subject}`
+ rescue ActiveResource::ResourceNotFound
+ say "No ticket with number: #{ticket}", :red
+ end
+
+ end
+ end
+end
View
3  lib/redmine-cli/issue.rb
@@ -1,3 +1,6 @@
+require 'thor'
+require 'active_resource'
+
module Redmine
module Cli
class Issue < ActiveResource::Base
Please sign in to comment.
Something went wrong with that request. Please try again.