Module: Git::Si::Actions
- Included in:
- SvnInterface
- Defined in:
- lib/git/si/actions.rb
Instance Method Summary collapse
- #do_add_action(args = []) ⇒ Object
- #do_atune_action ⇒ Object
- #do_commit_action ⇒ Object
- #do_diff_action(args = []) ⇒ Object
- #do_fetch_action ⇒ Object
- #do_init_action ⇒ Object
- #do_pull_action ⇒ Object
- #do_readd_action ⇒ Object
- #do_rebase_action ⇒ Object
- #do_status_action(args = []) ⇒ Object
Instance Method Details
#do_add_action(args = []) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/git/si/actions.rb', line 28 def do_add_action( args=[] ) on_local_branch do run_command( Git::Si::SvnControl.add_command( args ) ) run_command( Git::Si::GitControl.add_command( args ) ) end end |
#do_atune_action ⇒ Object
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/git/si/actions.rb', line 150 def do_atune_action "Atuning mirror branch with current svn state" on_mirror_branch do add_all_svn_files run_command( Git::Si::GitControl.commit_all_command ) end on_local_branch do run_command( Git::Si::GitControl.rebase_command( get_mirror_branch ) ) end end |
#do_commit_action ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/git/si/actions.rb', line 90 def do_commit_action local_branch = get_local_branch() if local_branch == 'master' "Please do not commit changes on the master branch" return end on_local_branch do raise Git::Si::GitError.new("There are local changes; please commit them before continuing.") if are_there_git_changes? "Adding any files that are not already in svn to ensure changes are committed." do_readd_action svn_diff = get_command_output( Git::Si::SvnControl.diff_command ) raise Git::Si::SvnError.new("There are no changes to commit.") if svn_diff.strip.empty? run_command( Git::Si::SvnControl.commit_command ) "commit complete!" if are_there_git_changes? and yes?( "Some files were added or modified during the commit; should I revert them? [y/N] ", :yellow ) run_command( Git::Si::GitControl.hard_reset_command ) end end "Updating mirror branch to latest commit" do_fetch_action delete_committed_branch( local_branch ) if yes?( "Do you want to switch to the master branch and delete the committed branch '#{local_branch}'? [y/N] ", :green ) end |
#do_diff_action(args = []) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/git/si/actions.rb', line 17 def do_diff_action( args=[] ) on_local_branch do return if do_revisions_differ() "Adding any files that are not already in svn to ensure an accurate diff." do_readd_action print_colordiff get_command_output( Git::Si::SvnControl.diff_command( args ) ) end end |
#do_fetch_action ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/git/si/actions.rb', line 62 def do_fetch_action stashed_changes = stash_local_changes on_mirror_branch do "Fetching remote data from svn" updated_files = get_command_output( Git::Si::SvnControl.update_command ) revert_files_to_svn_update( updated_files ) delete_files_after_svn_update( updated_files ) add_files_after_svn_update( updated_files ) run_command( Git::Si::GitControl.commit_revision_command( get_svn_revision ) ) end unstash_local_changes( stashed_changes ) "fetch complete!" end |
#do_init_action ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/git/si/actions.rb', line 120 def do_init_action on_local_branch do # check for svn repo run_command( Git::Si::SvnControl.info_command, { :allow_errors => true } ) raise Git::Si::SvnError.new("No svn repository was found here. Maybe you're in the wrong directory?") unless did_last_command_succeed? # make sure svn repo is up-to-date run_command( Git::Si::SvnControl.update_command ) make_a_commit = false # check for existing .git repo make_a_commit = true if create_git_repository() # check for existing .gitignore make_a_commit = true if create_gitignore() # make initial commit if make_a_commit "Making initial commit." run_command( Git::Si::GitControl.commit_revision_command(get_svn_revision) ) end # check for exiting mirror branch create_mirror_branch() "init complete!" end end |
#do_pull_action ⇒ Object
85 86 87 88 |
# File 'lib/git/si/actions.rb', line 85 def do_pull_action do_fetch_action do_rebase_action end |
#do_readd_action ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/git/si/actions.rb', line 35 def do_readd_action on_local_branch do files_to_add = [] Git::Si::SvnControl.parse_unknown_files( get_command_output( Git::Si::SvnControl.status_command ) ).each do |filename| if is_file_in_git?( filename ) files_to_add << filename if filename != '.gitignore' end end if files_to_add.empty? "There are no files to add." return end using_stderr do files_to_add.each do |filename| say filename end if yes? "Do you want to add the above files to svn? [y/N] ", :green run_command( Git::Si::SvnControl.add_command( files_to_add ) ) "Added files to svn that had been added to git." end end end end |
#do_rebase_action ⇒ Object
76 77 78 79 80 81 82 83 |
# File 'lib/git/si/actions.rb', line 76 def do_rebase_action on_local_branch do stashed_changes = stash_local_changes run_command( Git::Si::GitControl.rebase_command( get_mirror_branch ) ) unstash_local_changes( stashed_changes ) "rebase complete!" end end |
#do_status_action(args = []) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/git/si/actions.rb', line 9 def do_status_action( args=[] ) on_local_branch do return if do_revisions_differ() svn_status = get_command_output( Git::Si::SvnControl.status_command( args ) ) print_colordiff Git::Si::SvnControl.parse_svn_status( svn_status ).join( "\n" ) end end |