class Danger::DangerfileVSTSPlugin

Handles interacting with VSTS inside a Dangerfile. Provides a few functions which wrap ‘pr_json` and also through a few standard functions to simplify your code.

@example Warn when a PR is classed as work in progress

warn "PR is classed as Work in Progress" if vsts.pr_title.include? "[WIP]"

@example Declare a PR to be simple to avoid specific Danger rules

declared_trivial = (vsts.pr_title + vsts.pr_body).include?("#trivial")

@example Ensure there is a summary for a PR

failure "Please provide a summary in the Pull Request description" if vsts.pr_body.length < 5

@example Only accept PRs to the develop branch

failure "Please re-submit this PR to develop, we may have already fixed your issue." if vsts.branch_for_base != "develop"

@example Highlight when a celebrity makes a pull request

message "Welcome, Danger." if vsts.pr_author == "dangermcshane"

@example Ensure that all PRs have an assignee

warn "This PR does not have any assignees yet." unless vsts.pr_json["reviewers"].length == 0

@example Send a message with links to a collection of specific files

if git.modified_files.include? "config/*.js"
  config_files = git.modified_files.select { |path| path.include? "config/" }
  message "This PR changes #{ vsts.markdown_link(config_files) }"
end

@example Highlight with a clickable link if a Package.json is changed

warn "#{vsts.markdown_link("Package.json")} was edited." if git.modified_files.include? "Package.json"

@example Note an issue with a particular line on a file using the L[num] syntax, e.g. ‘#L23`

linter_json = `my_linter lint "file"`
results = JSON.parse linter_json
unless results.empty?
  file, line, warning = result.first
  warn "#{vsts.markdown_link("#{file}#L#{line}")} has linter issue: #{warning}."
end

@see danger/danger @tags core, vsts