ppgit 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +2 -0
- data/README.markdown +4 -2
- data/VERSION +1 -1
- data/bin/git-pp +9 -1
- data/bin/ppgit +9 -1
- data/lib/ppgit/usage.txt +1 -0
- data/lib/ppgit/utils.rb +23 -1
- data/ppgit.gemspec +3 -1
- data/spec/ppgit_clear_spec.rb +7 -0
- data/spec/ppgit_info_spec.rb +10 -0
- data/spec/ppgit_spec.rb +11 -2
- data/spec/spec_helper.rb +7 -0
- metadata +5 -3
    
        data/CHANGELOG
    CHANGED
    
    
    
        data/README.markdown
    CHANGED
    
    | @@ -8,11 +8,13 @@ When you're done, restore your local git config in a snap. | |
| 8 8 | 
             
            Quick Usage :
         | 
| 9 9 | 
             
            -------------
         | 
| 10 10 |  | 
| 11 | 
            -
            		$ ppgit john andy
         | 
| 12 11 | 
             
            		$ ppgit john andy andy_john@acme.com
         | 
| 13 | 
            -
             | 
| 14 12 | 
             
            		$ ppgit clear
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            		$ ppgit info
         | 
| 15 | 
            +
             | 
| 15 16 | 
             
            		$ ppgit --email_root *@acme.com
         | 
| 17 | 
            +
            		$ ppgit john andy
         | 
| 16 18 |  | 
| 17 19 | 
             
            remark : 'ppgit' is a synonym of 'git pp' => you can write
         | 
| 18 20 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0. | 
| 1 | 
            +
            0.3.0
         | 
    
        data/bin/git-pp
    CHANGED
    
    | @@ -5,6 +5,7 @@ require 'ppgit/utils' | |
| 5 5 |  | 
| 6 6 | 
             
            if 0 == ARGV.length
         | 
| 7 7 | 
             
              puts usage_message()
         | 
| 8 | 
            +
             | 
| 8 9 | 
             
            else
         | 
| 9 10 | 
             
              # for testing, we pass an explicit - temporary - config file.
         | 
| 10 11 | 
             
              file_part = argv_value_of('--file')
         | 
| @@ -15,10 +16,14 @@ else | |
| 15 16 | 
             
                set_git_value 'ppgit.emailroot' , emailroot
         | 
| 16 17 | 
             
              end
         | 
| 17 18 |  | 
| 18 | 
            -
              if ARGV == %w( | 
| 19 | 
            +
              if ARGV == %w(info)
         | 
| 20 | 
            +
              # puts info_message
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              elsif ARGV == %w(clear)
         | 
| 19 23 | 
             
                restore_git_value :from => 'user-before-ppgit.name' , :to => 'user.name'
         | 
| 20 24 | 
             
                restore_git_value :from => 'user-before-ppgit.email', :to => 'user.email'
         | 
| 21 25 | 
             
                `git config #{file_part} --remove-section user-before-ppgit`
         | 
| 26 | 
            +
              # puts info_message
         | 
| 22 27 |  | 
| 23 28 | 
             
              elsif [2,3].include?(ARGV.length)
         | 
| 24 29 |  | 
| @@ -35,5 +40,8 @@ else | |
| 35 40 | 
             
                if pair_email
         | 
| 36 41 | 
             
                  set_git_value 'user.email' , pair_email
         | 
| 37 42 | 
             
                end
         | 
| 43 | 
            +
              # puts info_message
         | 
| 38 44 | 
             
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              puts info_message
         | 
| 39 47 | 
             
            end
         | 
    
        data/bin/ppgit
    CHANGED
    
    | @@ -5,6 +5,7 @@ require 'ppgit/utils' | |
| 5 5 |  | 
| 6 6 | 
             
            if 0 == ARGV.length
         | 
| 7 7 | 
             
              puts usage_message()
         | 
| 8 | 
            +
             | 
| 8 9 | 
             
            else
         | 
| 9 10 | 
             
              # for testing, we pass an explicit - temporary - config file.
         | 
| 10 11 | 
             
              file_part = argv_value_of('--file')
         | 
| @@ -15,10 +16,14 @@ else | |
| 15 16 | 
             
                set_git_value 'ppgit.emailroot' , emailroot
         | 
| 16 17 | 
             
              end
         | 
| 17 18 |  | 
| 18 | 
            -
              if ARGV == %w( | 
| 19 | 
            +
              if ARGV == %w(info)
         | 
| 20 | 
            +
              # puts info_message
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              elsif ARGV == %w(clear)
         | 
| 19 23 | 
             
                restore_git_value :from => 'user-before-ppgit.name' , :to => 'user.name'
         | 
| 20 24 | 
             
                restore_git_value :from => 'user-before-ppgit.email', :to => 'user.email'
         | 
| 21 25 | 
             
                `git config #{file_part} --remove-section user-before-ppgit`
         | 
| 26 | 
            +
              # puts info_message
         | 
| 22 27 |  | 
| 23 28 | 
             
              elsif [2,3].include?(ARGV.length)
         | 
| 24 29 |  | 
| @@ -35,5 +40,8 @@ else | |
| 35 40 | 
             
                if pair_email
         | 
| 36 41 | 
             
                  set_git_value 'user.email' , pair_email
         | 
| 37 42 | 
             
                end
         | 
| 43 | 
            +
              # puts info_message
         | 
| 38 44 | 
             
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              puts info_message
         | 
| 39 47 | 
             
            end
         | 
    
        data/lib/ppgit/usage.txt
    CHANGED
    
    
    
        data/lib/ppgit/utils.rb
    CHANGED
    
    | @@ -48,4 +48,26 @@ end | |
| 48 48 | 
             
            def usage_message
         | 
| 49 49 | 
             
              path = File.expand_path(File.join(File.dirname(__FILE__), 'usage.txt'))
         | 
| 50 50 | 
             
              File.open(path).read
         | 
| 51 | 
            -
            end
         | 
| 51 | 
            +
            end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            def info_message
         | 
| 54 | 
            +
              name, email = get_git_value('user.name'), get_git_value('user.email')
         | 
| 55 | 
            +
              email_root  = get_git_value('ppgit.emailroot')
         | 
| 56 | 
            +
              s = ["\n~/.gitconfig :", "  ..."]
         | 
| 57 | 
            +
              s << '  -------------------------------------------------------'
         | 
| 58 | 
            +
              s << '  [user]'
         | 
| 59 | 
            +
              s << "    name  = #{name }" unless blank?(name )
         | 
| 60 | 
            +
              s << "    email = #{email}" unless blank?(email)
         | 
| 61 | 
            +
              s << '  -------------------------------------------------------'
         | 
| 62 | 
            +
              s << '  [ppgit]'
         | 
| 63 | 
            +
              s << "    emailroot = #{email_root}" unless blank?(email_root)
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              name, email = get_git_value('user-before-ppgit.name'), get_git_value('user-before-ppgit.email')
         | 
| 66 | 
            +
              s << '  [user-before-ppgit]'
         | 
| 67 | 
            +
              s << "    name  = #{name }" unless blank?(name )
         | 
| 68 | 
            +
              s << "    email = #{email}" unless blank?(email)
         | 
| 69 | 
            +
              s << '  -------------------------------------------------------'
         | 
| 70 | 
            +
              s << '  ...'
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              s.join("\n")
         | 
| 73 | 
            +
            end
         | 
    
        data/ppgit.gemspec
    CHANGED
    
    | @@ -5,7 +5,7 @@ | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |s|
         | 
| 7 7 | 
             
              s.name = %q{ppgit}
         | 
| 8 | 
            -
              s.version = "0. | 
| 8 | 
            +
              s.version = "0.3.0"
         | 
| 9 9 |  | 
| 10 10 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 11 11 | 
             
              s.authors = ["Alain Ravet"]
         | 
| @@ -33,6 +33,7 @@ Gem::Specification.new do |s| | |
| 33 33 | 
             
                 "ppgit.gemspec",
         | 
| 34 34 | 
             
                 "spec/ppgit_clear_spec.rb",
         | 
| 35 35 | 
             
                 "spec/ppgit_email_root_spec.rb",
         | 
| 36 | 
            +
                 "spec/ppgit_info_spec.rb",
         | 
| 36 37 | 
             
                 "spec/ppgit_spec.rb",
         | 
| 37 38 | 
             
                 "spec/ppgit_usage_spec.rb",
         | 
| 38 39 | 
             
                 "spec/spec.opts",
         | 
| @@ -46,6 +47,7 @@ Gem::Specification.new do |s| | |
| 46 47 | 
             
              s.test_files = [
         | 
| 47 48 | 
             
                "spec/ppgit_clear_spec.rb",
         | 
| 48 49 | 
             
                 "spec/ppgit_email_root_spec.rb",
         | 
| 50 | 
            +
                 "spec/ppgit_info_spec.rb",
         | 
| 49 51 | 
             
                 "spec/ppgit_spec.rb",
         | 
| 50 52 | 
             
                 "spec/ppgit_usage_spec.rb",
         | 
| 51 53 | 
             
                 "spec/spec_helper.rb"
         | 
    
        data/spec/ppgit_clear_spec.rb
    CHANGED
    
    | @@ -46,4 +46,11 @@ describe "`ppgit clear`" do | |
| 46 46 | 
             
                check_command_result(@cmd, before, expected)
         | 
| 47 47 | 
             
              end
         | 
| 48 48 |  | 
| 49 | 
            +
              it "displays the info after the fact" do
         | 
| 50 | 
            +
                before   = [  '[ppgit]'                         ,
         | 
| 51 | 
            +
                              '  emailroot = old+*@gmail.com'  ]
         | 
| 52 | 
            +
                output = execute_command(@cmd, before)
         | 
| 53 | 
            +
                output.should match(/\[user\].*\[ppgit\].*emailroot.*\[user-before-ppgit\].*/mi)
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 49 56 | 
             
            end
         | 
    
        data/spec/ppgit_spec.rb
    CHANGED
    
    | @@ -100,6 +100,9 @@ describe "`ppgit john andy andy_john@acme.com`" do | |
| 100 100 | 
             
                              '  name = Alain Ravet'            ,
         | 
| 101 101 | 
             
                              '  email = alainravet@gmail.com'  ]
         | 
| 102 102 |  | 
| 103 | 
            +
                before do
         | 
| 104 | 
            +
                  @cmd = "#{PPGIT_CMD} artie zane artie_zane@test.com"
         | 
| 105 | 
            +
                end
         | 
| 103 106 |  | 
| 104 107 | 
             
                it "does not overwrite the values stored in user-before-ppgit" do
         | 
| 105 108 | 
             
                  expected = [  '[user]'                        ,
         | 
| @@ -110,8 +113,14 @@ describe "`ppgit john andy andy_john@acme.com`" do | |
| 110 113 | 
             
                                '  name = Alain Ravet'          , # not touched
         | 
| 111 114 | 
             
                                '  email = alainravet@gmail.com'] #  ..
         | 
| 112 115 |  | 
| 113 | 
            -
             | 
| 114 | 
            -
                  check_command_result(cmd, before, expected)
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                  check_command_result(@cmd, before, expected)
         | 
| 115 118 | 
             
                end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                it "displays the info after the fact" do
         | 
| 121 | 
            +
                  output = execute_command(@cmd, before)
         | 
| 122 | 
            +
                  output.should match(/\[user\].*artie_zane.*\[ppgit\].*\[user-before-ppgit\].*alainravet@gmail.com/mi)
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
             | 
| 116 125 | 
             
              end
         | 
| 117 126 | 
             
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -47,3 +47,10 @@ def check_command_result(git_command, before, expected) | |
| 47 47 | 
             
              actual_text = File.open(config_file_path).read.gsub(/\t/, '  ').chomp
         | 
| 48 48 | 
             
              actual_text.should == expected
         | 
| 49 49 | 
             
            end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
            def execute_command(git_command, before)
         | 
| 52 | 
            +
              before = before.join("\n")
         | 
| 53 | 
            +
              config_file_path = temp_from_string(before).path
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              output = `#{git_command} --file #{config_file_path}`
         | 
| 56 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: ppgit
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 19
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 | 
            -
              -  | 
| 8 | 
            +
              - 3
         | 
| 9 9 | 
             
              - 0
         | 
| 10 | 
            -
              version: 0. | 
| 10 | 
            +
              version: 0.3.0
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Alain Ravet
         | 
| @@ -60,6 +60,7 @@ files: | |
| 60 60 | 
             
            - ppgit.gemspec
         | 
| 61 61 | 
             
            - spec/ppgit_clear_spec.rb
         | 
| 62 62 | 
             
            - spec/ppgit_email_root_spec.rb
         | 
| 63 | 
            +
            - spec/ppgit_info_spec.rb
         | 
| 63 64 | 
             
            - spec/ppgit_spec.rb
         | 
| 64 65 | 
             
            - spec/ppgit_usage_spec.rb
         | 
| 65 66 | 
             
            - spec/spec.opts
         | 
| @@ -101,6 +102,7 @@ summary: git users' pairs switcher | |
| 101 102 | 
             
            test_files: 
         | 
| 102 103 | 
             
            - spec/ppgit_clear_spec.rb
         | 
| 103 104 | 
             
            - spec/ppgit_email_root_spec.rb
         | 
| 105 | 
            +
            - spec/ppgit_info_spec.rb
         | 
| 104 106 | 
             
            - spec/ppgit_spec.rb
         | 
| 105 107 | 
             
            - spec/ppgit_usage_spec.rb
         | 
| 106 108 | 
             
            - spec/spec_helper.rb
         |