geordi 0.9.12 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- branch = ARGV[0] or raise "Need the branch name as first argument"
3
+ # detect current branch
4
+ current_branch = (%x{git branch 2> /dev/null}.grep(/^\*/).first || '').scan(/^\* (.+)$/).flatten.first
4
5
 
5
- `git status`.include?('working directory clean') or raise 'Dirty working directory. Nothing was pushed.'
6
- `git checkout #{branch}`
7
- `git push origin #{branch}`
8
- `git config branch.#{branch}.remote origin`
9
- `git config branch.#{branch}.merge #{branch}`
6
+ # use branch passed via command line or current branch if none was given
7
+ branch = ARGV[0] || current_branch || raise("Need the branch name as first argument since the current branch could not be detected automatically")
8
+
9
+ # switch the branch if it is not the current branch
10
+ if branch != current_branch
11
+ `git status`.include?('working directory clean') or raise 'Dirty working directory. Nothing was pushed.'
12
+ `git checkout #{branch}`
13
+ end
14
+
15
+ # push branch to remote and track it
16
+ `git push -u origin #{branch}`
10
17
 
11
18
  puts "#{branch} is now tracking origin/#{branch}"
12
19
 
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '0.9.12'
2
+ VERSION = '0.10.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- hash: 35
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 9
9
- - 12
10
- version: 0.9.12
8
+ - 10
9
+ - 0
10
+ version: 0.10.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-04-11 00:00:00 +02:00
18
+ date: 2012-04-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21