Module: Canvas::Workflow::Travis
- Defined in:
- lib/canvas/workflow/travis.rb
Class Method Summary collapse
-
.created?(file) ⇒ Boolean
Has
file
been created since the last successful build?. -
.modified?(file) ⇒ Boolean
Has
file
been modified since the last successful build?. -
.removed?(file) ⇒ Boolean
Has
file
been removed since the last successful build?.
Class Method Details
.created?(file) ⇒ Boolean
Behavior is undefined if the reason that there is no previous successful build is because it was struck from the git history. If this is the case, then there is no reliable way to determine which files have been changed without brute-force checking every file against the Canvas site.
Has file
been created since the last successful build?
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/canvas/workflow/travis.rb', line 53 def self.created?(file) if commit_sha.nil? # get the list of all files on this branch being tracked by git @created ||= `git ls-tree -r #{branch} --name-only` else # get the list of files that have been created since the last passed # commit @created ||= `git diff --diff-filter=AR --name-only #{commit_sha}` end raise Error.new($?.exitstatus) if $?.exitstatus != 0 # check if the param file has been created @created.include?(file) end |
.modified?(file) ⇒ Boolean
Behavior is undefined if the reason that there is no previous successful build is because it was struck from the git history. If this is the case, then there is no reliable way to determine which files have been changed without brute-force checking every file against the Canvas site.
Has file
been modified since the last successful build?
77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/canvas/workflow/travis.rb', line 77 def self.modified?(file) if commit_sha.nil? # get the list of all files on this branch being tracked by git @modified ||= `git ls-tree -r #{branch} --name-only` else # get the list of files that have been modified since the last # passed commit @modified ||= `git diff --diff-filter=M --name-only #{commit_sha}` end raise Error.new($?.exitstatus) if $?.exitstatus != 0 # check if the param file has been modified @modified.include?(file) end |
.removed?(file) ⇒ Boolean
Has file
been removed since the last successful build?
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/canvas/workflow/travis.rb', line 29 def self.removed?(file) if commit_sha.nil? # no files have been removed, since there is no previous successful # build on this branch else # get the list of files that have been deleted since the last passed # commit @removed ||= `git diff --diff-filter=D --name-only #{commit_sha}` raise Error.new($?.exitstatus) if $?.exitstatus != 0 end # check if the param file has been removed @removed.include?(file) end |