gitsu 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.licenseignore +2 -0
  3. data/.simplecov +16 -0
  4. data/.travis.yml +19 -2
  5. data/Gemfile +17 -1
  6. data/README.md +36 -7
  7. data/Rakefile +37 -3
  8. data/TODO +4 -2
  9. data/bin/git-su +15 -0
  10. data/bin/git-whoami +15 -0
  11. data/features/add_user.feature +16 -0
  12. data/features/change_user_in_different_scopes.feature +16 -0
  13. data/features/clear_user.feature +16 -0
  14. data/features/configure_default_scope.feature +22 -2
  15. data/features/edit_config.feature +16 -0
  16. data/features/list_users.feature +16 -0
  17. data/features/print_current_user.feature +16 -0
  18. data/features/print_options.feature +16 -0
  19. data/features/step_definitions/gitsu_steps.rb +33 -12
  20. data/features/support/env.rb +16 -0
  21. data/features/switch_to_fully_qualified_user.feature +21 -0
  22. data/features/switch_to_multiple_users.feature +64 -0
  23. data/features/switch_to_stored_user.feature +16 -0
  24. data/gitsu.gemspec +20 -3
  25. data/lib/gitsu.rb +17 -0
  26. data/lib/gitsu/array.rb +31 -0
  27. data/lib/gitsu/config_repository.rb +49 -0
  28. data/lib/gitsu/factory.rb +26 -3
  29. data/lib/gitsu/git.rb +44 -35
  30. data/lib/gitsu/gitsu.rb +27 -3
  31. data/lib/gitsu/runner.rb +16 -0
  32. data/lib/gitsu/shell.rb +17 -2
  33. data/lib/gitsu/switcher.rb +68 -30
  34. data/lib/gitsu/user.rb +80 -11
  35. data/lib/gitsu/user_file.rb +18 -2
  36. data/lib/gitsu/user_list.rb +68 -12
  37. data/lib/gitsu/version.rb +17 -1
  38. data/man/git-su.1.ronn +36 -4
  39. data/spec/gitsu/array_spec.rb +71 -0
  40. data/spec/gitsu/bin_spec.rb +16 -0
  41. data/spec/gitsu/config_repository_spec.rb +67 -0
  42. data/spec/gitsu/git_spec.rb +36 -15
  43. data/spec/gitsu/gitsu_spec.rb +41 -18
  44. data/spec/gitsu/runner_spec.rb +16 -0
  45. data/spec/gitsu/shell_spec.rb +55 -0
  46. data/spec/gitsu/switcher_spec.rb +53 -13
  47. data/spec/gitsu/user_file_spec.rb +91 -0
  48. data/spec/gitsu/user_list_spec.rb +112 -41
  49. data/spec/gitsu/user_spec.rb +97 -0
  50. data/spec/gitsu/version_spec.rb +16 -0
  51. data/spec/spec_helper.rb +16 -0
  52. metadata +45 -28
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 335199ff875a33b70625eb785f9ca8bd0897e3cf
4
+ data.tar.gz: 77215508c1b65a3fcd21380cf92a6d69c6c8f306
5
+ SHA512:
6
+ metadata.gz: 6ab45ca27cb4e26476be19156dd9490bdf31c6c0405f8f8eab8f1414fea9226680df473f25fbc3823c1bd2dd07b88e8ebf35852e71bf702864e3c7523ca2c75d
7
+ data.tar.gz: 55e58d9abab342e1ae3ab23c986e8356a08ae6467e7a9519c747dc6149de210f02b7eb5a697bd1045161d43ec8eaa6e8f3a54348abfb7634d99a587917106642
@@ -0,0 +1,2 @@
1
+ TODO
2
+ .gitignore
data/.simplecov CHANGED
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  SimpleCov.start do
2
18
  add_filter "/spec/"
3
19
  add_filter "/features/"
@@ -1,9 +1,26 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  language: ruby
2
18
  rvm:
3
19
  - "1.8.7"
4
20
  - "1.9.2"
5
21
  - "1.9.3"
6
- - jruby-18mode # JRuby in 1.8 mode
7
- - jruby-19mode # JRuby in 1.9 mode
22
+ - "2.0.0"
23
+ - jruby-18mode
24
+ - jruby-19mode
8
25
  - rbx-18mode
9
26
  - rbx-19mode
data/Gemfile CHANGED
@@ -1,4 +1,20 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  source 'https://rubygems.org'
2
18
 
3
- # Specify your gem's dependencies in git-su.gemspec
19
+ # Specify all dependencies in gitsu.gemspec
4
20
  gemspec
data/README.md CHANGED
@@ -4,8 +4,11 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/drrb/gitsu/badge.png?branch=master)](https://coveralls.io/r/drrb/gitsu)
5
5
  [![Code Climate](https://codeclimate.com/github/drrb/gitsu.png)](https://codeclimate.com/github/drrb/gitsu)
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/gitsu.png)](http://badge.fury.io/rb/gitsu)
8
+
7
9
  Gitsu helps to manage your Git users, by making it easy to switch
8
- between users.
10
+ between users. Gitsu also supports pair programming by allowing you
11
+ switch to multiple users at once!
9
12
 
10
13
  ## Installation
11
14
 
@@ -27,20 +30,46 @@ To make it easier to switch users, tell Gitsu about some users.
27
30
  $ git su --add "Raphe Rackstraw <rrack@example.com>"
28
31
  $ git su jg
29
32
 
30
- Switched to user John Galt <jgalt@example.com>
33
+ Switched local user to John Galt <jgalt@example.com>
31
34
 
32
35
  $ git su raphe
33
36
 
34
- Switched to user Raphe Rackstraw <rrack@example.com>
37
+ Switched local user to Raphe Rackstraw <rrack@example.com>
38
+
39
+ To pair with your friend switch to both users at once
40
+
41
+ $ git su jg rr
42
+
43
+ Switched local user to John Galt and Raphe Rackstraw <dev+jgalt+rrack@example.com>
35
44
 
36
45
  ## Documentation
37
46
 
38
- For more information, see [the documentation](http://drrb.github.com/gitsu)
47
+ For more information, see [the documentation](http://drrb.github.io/gitsu)
39
48
 
40
49
  ## Contributing
41
50
 
42
51
  1. Fork it
43
52
  2. Create your feature branch (`git checkout -b my-new-feature`)
44
- 3. Commit your changes (`git commit -am 'Add some feature'`)
45
- 4. Push to the branch (`git push origin my-new-feature`)
46
- 5. Create new Pull Request
53
+ 3. Make your changes, and add tests for them
54
+ 4. Test your changes (`rake`)
55
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 6. Push to the branch (`git push origin my-new-feature`)
57
+ 7. Create new Pull Request
58
+
59
+ ## License
60
+
61
+ Gitsu
62
+ Copyright (C) 2013 drrb
63
+
64
+ This program is free software: you can redistribute it and/or modify
65
+ it under the terms of the GNU General Public License as published by
66
+ the Free Software Foundation, either version 3 of the License, or
67
+ (at your option) any later version.
68
+
69
+ This program is distributed in the hope that it will be useful,
70
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
71
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72
+ GNU General Public License for more details.
73
+
74
+ You should have received a copy of the GNU General Public License
75
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
data/Rakefile CHANGED
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  lib_path = File.expand_path('../lib', __FILE__)
2
18
  $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include? lib_path
3
19
  require 'gitsu'
@@ -12,8 +28,17 @@ RSpec::Core::RakeTask.new(:spec)
12
28
 
13
29
  task :default => [:spec, :features, 'coveralls:push']
14
30
 
15
- task :push_release => [:spec, :features] do
31
+ task :verify do
32
+ system "rvm all do rake"
33
+ end
34
+
35
+ task 'push-release' => ['check-license', :verify] do
16
36
  git = GitSu::Git.new(GitSu::Shell.new)
37
+
38
+ unless git.list_files(:modified).empty?
39
+ abort("Changes in working directory: not releasing")
40
+ end
41
+
17
42
  version = GitSu::Version.prompt($stdin, $stdout, "Enter the version to release", GitSu::Version.current)
18
43
  next_version = GitSu::Version.prompt($stdin, $stdout, "Enter the next development version", version.next_minor)
19
44
 
@@ -21,13 +46,22 @@ task :push_release => [:spec, :features] do
21
46
 
22
47
  update_version(version)
23
48
  git.commit("lib/gitsu/version.rb", "Preparing for release #{version}")
24
- # TODO: check if this works as a symbol, otherwise just use string
25
- #Rake::Task["release"].invoke
26
49
  Rake::Task[:release].invoke
27
50
  update_version(next_version)
28
51
  git.commit("lib/gitsu/version.rb", "Preparing for next development iteration")
29
52
  end
30
53
 
54
+ task 'check-license' do
55
+ puts "Checking that all program files contain license headers"
56
+
57
+ files = `git ls-files`.split "\n"
58
+ ignored_files = File.read(".licenseignore").split("\n") << ".licenseignore"
59
+ offending_files = files.reject { |file| File.read(file).include? "WITHOUT ANY WARRANTY" } - ignored_files
60
+ unless offending_files.empty?
61
+ abort("ERROR: THE FOLLOWING FILES HAVE NO LICENSE HEADERS: \n" + offending_files.join("\n"))
62
+ end
63
+ end
64
+
31
65
  def update_version(new_version)
32
66
  system(%q[sed -i '' -E 's/VERSION = ".*"/VERSION = "] + new_version.to_s + %q["/' lib/gitsu/version.rb])
33
67
  end
data/TODO CHANGED
@@ -1,11 +1,13 @@
1
1
  Features
2
2
  --------
3
- Support multiple users at once for pairing
3
+ Enable interactive/noninteractive mode for multi/ambiguous user selection
4
+ Enable interactive adding of users
5
+ Enable pairs to be specified in the config as arrays
4
6
  Make colors configurable because people like that stuff
5
7
 
6
8
  Tasks
7
9
  --------
8
- Check for changes (and abort if you find them) during release
10
+ Generate man page when building
9
11
  Use a prerelease version (e.g. "1.2.3.pre") for Gem working version
10
12
 
11
13
  Bugs
data/bin/git-su CHANGED
@@ -1,4 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
+ # Gitsu
3
+ # Copyright (C) 2013 drrb
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
2
17
 
3
18
  lib_path = File.expand_path('../../lib', __FILE__)
4
19
  $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include? lib_path
@@ -1,4 +1,19 @@
1
1
  #!/usr/bin/env ruby
2
+ # Gitsu
3
+ # Copyright (C) 2013 drrb
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
2
17
 
3
18
  lib_path = File.expand_path('../../lib', __FILE__)
4
19
  $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include? lib_path
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Add user
2
18
  As a new user
3
19
  I want to add myself to the GitSu config
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Change user in different scopes
2
18
  As a user with multiple projects
3
19
  I want to change my user in different scopes
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Clear user
2
18
  As a user
3
19
  I want to clear my Git configured user
@@ -1,9 +1,29 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Configure default scope
2
18
  As a user of a shared environment
3
19
  I want to configure the default scope
4
20
  So that I can change the user for all projects at once
5
21
 
6
- Scenario: Default to global scope
7
- Given the Git configuration has "git-su.defaultSelectScope" set to "global"
22
+ Scenario: No default scope specified
23
+ When I type "git su 'John Galt <jgalt@example.com>'"
24
+ Then I should see "Switched local user to John Galt <jgalt@example.com>"
25
+
26
+ Scenario: Default scope specified
27
+ Given the Git configuration has "gitsu.defaultSelectScope" set to "global"
8
28
  When I type "git su 'John Galt <jgalt@example.com>'"
9
29
  Then I should see "Switched global user to John Galt <jgalt@example.com>"
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Edit config file
2
18
  As a user
3
19
  I want to quickly open the config file in an editor
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: List users
2
18
  As a user
3
19
  I want to list all users
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Print the current user
2
18
  As a user
3
19
  I want to see who is currently logged in
@@ -1,3 +1,19 @@
1
+ # Gitsu
2
+ # Copyright (C) 2013 drrb
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
1
17
  Feature: Print options
2
18
  As a user
3
19
  I want to view Gitsu's options