Module: Redcar::Scm::Model
- Included in:
- Git::Manager, Redcar::Scm::Mercurial::Manager, Subversion::Manager
- Defined in:
- plugins/scm/lib/scm/model.rb
Overview
This class acts as an interface definition for SCM's. Override as much as possible that is supported by your SCM of choice.
Instance Method Summary (collapse)
-
- (Object) adapter(old_adapter)
Allows the SCM to provide a custom adapter which is injected into the project instead of old_adapter.
-
- (Array<String>) branches
REQUIRED for :switch_branch and :merge.
-
- (Object) commit!(message, change = nil)
REQUIRED for :commit.
-
- (Object) commit_message(change = nil)
REQUIRED for :commit.
-
- (Object) current_branch
REQUIRED for :switch_branch.
-
- (Object) index_add(change)
REQUIRED for :index.
-
- (Object) index_delete(change)
REQUIRED for :index.
-
- (Object) index_ignore(change)
REQUIRED for :index.
-
- (Object) index_ignore_all(extension, change)
REQUIRED for :index.
-
- (Object) index_restore(change)
REQUIRED for :index.
-
- (Object) index_revert(change)
REQUIRED for :index.
-
- (Object) index_save(change)
REQUIRED for :index.
-
- (Object) index_unsave(change)
REQUIRED for :index.
-
- (Array<Redcar::Scm::ScmChangesMirror::Change>) indexed_changes
REQUIRED for :commit if :index is supported.
-
- (Object) init!(path)
REQUIRED for :init.
-
- (Object) load(path)
REQUIRED.
-
- (Object) merge!(branch)
REQUIRED for :merge.
-
- (Object) pull!(remote = nil)
REQUIRED for :pull and :pull_targetted.
-
- (Object) pull_targets
REQUIRED for :pull_targetted.
-
- (Object) push!(target = '')
REQUIRED for :push.
-
- (Array<Redcar::Scm::ScmCommitsMirror::CommitsNode>) push_targets
RECOMMENDED for :push.
-
- (Object) refresh
RECOMMENDED.
-
- (Object) remote_init(repo_path, target_directory)
REQUIRED for :remote_init.
-
- (Boolean) repository?(path)
REQUIRED.
-
- (Object) repository_type
Returns a string giving the name of the SCM.
-
- (Object) supported_commands
REQUIRED to be useful.
-
- (Object) switch!(branch)
REQUIRED for :switch_branch.
-
- (Object) translations
This method allows SCM's to override the default names for different commands and bring them into line with the normal vocabulary in their respective worlds.
-
- (Array<Redcar::Scm::ScmChangesMirror::Change>) uncommited_changes
REQUIRED for :commit if :index is not supported.
-
- (Array<Redcar::Scm::ScmChangesMirror::Change>) unindexed_changes
REQUIRED for :commit if :index is supported.
-
- (Array<Redcar::Scm::ScmCommitsMirror::Commit>) unpushed_commits(target = '')
REQUIRED for :push.
Instance Method Details
- (Object) adapter(old_adapter)
Allows the SCM to provide a custom adapter which is injected into the project instead of old_adapter. This allows interception of file modifications such as move and copy, which you may wish to do via your SCM instead of normal file system operations.
270 271 272 |
# File 'plugins/scm/lib/scm/model.rb', line 270 def adapter(old_adapter) nil end |
- (Array<String>) branches
REQUIRED for :switch_branch and :merge. Returns an array of branch names.
243 244 245 246 |
# File 'plugins/scm/lib/scm/model.rb', line 243 def branches raise "Scm.branches not implemented." if supported_commands.include?(:switch_branch) or supported_commands.include?(:merge) [] end |
- (Object) commit!(message, change = nil)
REQUIRED for :commit. Commits the currently indexed changes in the subproject.
you don't provide these.
186 187 188 189 |
# File 'plugins/scm/lib/scm/model.rb', line 186 def commit!(, change=nil) raise "Scm.commit! not implemented." if supported_commands.include?(:index) nil end |
- (Object) commit_message(change = nil)
REQUIRED for :commit. Gets a default commit message for the currently indexed changes.
you don't provide these.
196 197 198 |
# File 'plugins/scm/lib/scm/model.rb', line 196 def (change=nil) "\n\n# Please enter your commit message above." end |
- (Object) current_branch
REQUIRED for :switch_branch. Returns the name of the current branch.
249 250 251 252 |
# File 'plugins/scm/lib/scm/model.rb', line 249 def current_branch raise "Scm.current_branch not implemented." if supported_commands.include?(:switch_branch) '' end |
- (Object) index_add(change)
REQUIRED for :index. Adds a new file to the index.
131 132 133 134 |
# File 'plugins/scm/lib/scm/model.rb', line 131 def index_add(change) raise "Scm.index_add not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_delete(change)
REQUIRED for :index. Marks a file as deleted in the index.
176 177 178 179 |
# File 'plugins/scm/lib/scm/model.rb', line 176 def index_delete(change) raise "Scm.index_delete not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_ignore(change)
REQUIRED for :index. Ignores a new file so it won't show in changes.
137 138 139 140 |
# File 'plugins/scm/lib/scm/model.rb', line 137 def index_ignore(change) raise "Scm.index_ignore not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_ignore_all(extension, change)
REQUIRED for :index. Ignores all files with a certain extension so they won't show in changes.
144 145 146 147 |
# File 'plugins/scm/lib/scm/model.rb', line 144 def index_ignore_all(extension, change) raise "Scm.index_ignore_all not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_restore(change)
REQUIRED for :index. Restores a file to the last known state of the file. This may be from the index, or the last commit.
170 171 172 173 |
# File 'plugins/scm/lib/scm/model.rb', line 170 def index_restore(change) raise "Scm.index_restore not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_revert(change)
REQUIRED for :index. Reverts a file to its last commited state.
150 151 152 153 |
# File 'plugins/scm/lib/scm/model.rb', line 150 def index_revert(change) raise "Scm.index_revert not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_save(change)
REQUIRED for :index. Saves changes made to a file in the index.
163 164 165 166 |
# File 'plugins/scm/lib/scm/model.rb', line 163 def index_save(change) raise "Scm.index_save not implemented" if supported_commands.include?(:index) nil end |
- (Object) index_unsave(change)
REQUIRED for :index. Reverts a file in the index back to it's last commited state, but leaves the file intact.
157 158 159 160 |
# File 'plugins/scm/lib/scm/model.rb', line 157 def index_unsave(change) raise "Scm.index_unsave not implemented" if supported_commands.include?(:index) nil end |
- (Array<Redcar::Scm::ScmChangesMirror::Change>) indexed_changes
REQUIRED for :commit if :index is supported. Returns an array of changes currently in the index.
116 117 118 119 |
# File 'plugins/scm/lib/scm/model.rb', line 116 def indexed_changes raise "Scm.indexed_changes not implemented." if supported_commands.include?(:commit) [] end |
- (Object) init!(path)
REQUIRED for :init. Initialise a repository in a given path. Returns false on error.
90 91 92 93 |
# File 'plugins/scm/lib/scm/model.rb', line 90 def init!(path) raise "Scm.init not implemented." if supported_commands.include?(:init) nil end |
- (Object) load(path)
REQUIRED. Initialises the SCM with a path. This path should be used for all future interactions. Repeated calls to load should be treated as a breaking error.
21 22 23 |
# File 'plugins/scm/lib/scm/model.rb', line 21 def load(path) raise "Scm.load not implemented." end |
- (Object) merge!(branch)
REQUIRED for :merge. Merges the target branch with the current one.
261 262 263 264 |
# File 'plugins/scm/lib/scm/model.rb', line 261 def merge!(branch) raise "Scm.switch! not implemented." if supported_commands.include?(:merge) nil end |
- (Object) pull!(remote = nil)
REQUIRED for :pull and :pull_targetted. Pulls all remote changesets from the remote repository.
Note: If you only support :pull, you can implement this without the argument. It will never be called with an explicit nil.
229 230 231 232 |
# File 'plugins/scm/lib/scm/model.rb', line 229 def pull!(remote=nil) raise "Scm.pull! not implemented." if supported_commands.include?(:pull) nil end |
- (Object) pull_targets
REQUIRED for :pull_targetted. Returns an array of pull targets.
235 236 237 238 |
# File 'plugins/scm/lib/scm/model.rb', line 235 def pull_targets raise "Scm.pull_targets not implemented." if supported_commands.include?(:pull_targeted) [] end |
- (Object) push!(target = '')
REQUIRED for :push. Pushes all current changesets to the remote repository for the given target only.
211 212 213 214 |
# File 'plugins/scm/lib/scm/model.rb', line 211 def push!(target='') raise "Scm.push! not implemented." if supported_commands.include?(:push) nil end |
- (Array<Redcar::Scm::ScmCommitsMirror::CommitsNode>) push_targets
RECOMMENDED for :push. Allows to provide a list of targets that can be pushed.
220 221 222 |
# File 'plugins/scm/lib/scm/model.rb', line 220 def push_targets [] end |
- (Object) refresh
RECOMMENDED. If we call this method, than we expect the repository to return all fresh data for any subsequent calls. Any caching should be reset.
28 29 30 |
# File 'plugins/scm/lib/scm/model.rb', line 28 def refresh nil end |
- (Object) remote_init(repo_path, target_directory)
REQUIRED for :remote_init. Initialize a repository from a url or file path, like SVN 'checkout' or git 'clone' Returns false on error
98 99 100 101 |
# File 'plugins/scm/lib/scm/model.rb', line 98 def remote_init(repo_path,target_directory) raise "Scm.remote_init not implemented." if supported_commands.include?(:remote_init) nil end |
- (Boolean) repository?(path)
REQUIRED. Checks if a given directory is a repository supported by the SCM.
14 15 16 |
# File 'plugins/scm/lib/scm/model.rb', line 14 def repository?(path) raise "Scm.repository? not implemented." end |
- (Object) repository_type
Returns a string giving the name of the SCM
8 9 10 |
# File 'plugins/scm/lib/scm/model.rb', line 8 def repository_type "" end |
- (Object) supported_commands
REQUIRED to be useful. If no commands are supported, than the SCM will will essentially be useless. These commands loosely translate to the common operations of a distributed CVS.
Supported values to date:
* :init
* :remote_init
* :push
* :pull
* :pull_targetted
* :commit
* :index
* :switch_branch
* :merge
Note about non-distributed CVS's: If your CVS doesn't support local commits, ie. subversion, then implement :commit and :pull, and then provide translations via the translations method. :remote_init can fill the gap for initializing a non-distributed VCS.
51 52 53 |
# File 'plugins/scm/lib/scm/model.rb', line 51 def supported_commands [] end |
- (Object) switch!(branch)
REQUIRED for :switch_branch. Switches to the named branch.
255 256 257 258 |
# File 'plugins/scm/lib/scm/model.rb', line 255 def switch!(branch) raise "Scm.switch! not implemented." if supported_commands.include?(:switch_branch) nil end |
- (Object) translations
This method allows SCM's to override the default names for different commands and bring them into line with the normal vocabulary in their respective worlds. ie, SVN calls :commit and :pull “checkin” and “checkout” respectively. If you overload this method, you need to provide names for all commands you support with supported_commands
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'plugins/scm/lib/scm/model.rb', line 60 def translations { :init => "Initialise " + repository_type.capitalize, :remote_init => "Initialize "+ repository_type.capitalize+" from remote repository", :remote_init_path => "Repository URL", :remote_init_target => "Target Directory", :push => "Push Changesets", :unpushed_commits => "Unpushed commits", :pull => "Pull Changesets", :pull_targetted => "Pull...", :commit => "Commit Changes", :uncommited_changes => "Uncommited changes", :indexed_changes => "Indexed changes", :unindexed_changes => "Unindexed changes", :index_add => "Add File", :index_ignore => "Ignore File", :index_ignore_all => "Ignore All %s Files", :index_save => "Index Changes", :index_unsave => "Revert Index", :index_revert => "Revert Changes", :index_restore => "Restore File", :index_delete => "Delete File", :commitable => "Commit Changes to Subproject", :switch_branch => "Switch Branch", :merge => "Merge...", } end |
- (Array<Redcar::Scm::ScmChangesMirror::Change>) uncommited_changes
REQUIRED for :commit if :index is not supported. Returns an array of changes currently waiting for commit.
107 108 109 110 |
# File 'plugins/scm/lib/scm/model.rb', line 107 def uncommited_changes raise "Scm.uncommited_changes not implemented." if supported_commands.include?(:commit) [] end |
- (Array<Redcar::Scm::ScmChangesMirror::Change>) unindexed_changes
REQUIRED for :commit if :index is supported. Returns an array of changes currently not in the index.
125 126 127 128 |
# File 'plugins/scm/lib/scm/model.rb', line 125 def unindexed_changes raise "Scm.unindexed_changes not implemented." if supported_commands.include?(:commit) [] end |
- (Array<Redcar::Scm::ScmCommitsMirror::Commit>) unpushed_commits(target = '')
REQUIRED for :push. Returns an array of unpushed changesets for a given target.
204 205 206 207 |
# File 'plugins/scm/lib/scm/model.rb', line 204 def unpushed_commits(target='') raise "Scm.unpushed_commits not implemented." if supported_commands.include?(:push) nil end |