Skip to content

Instantly share code, notes, and snippets.

@rplugge
Forked from TessaGit/questions-workflow-tools.md
Last active September 29, 2015 17:23
Show Gist options
  • Save rplugge/31abc4857c526700785e to your computer and use it in GitHub Desktop.
Save rplugge/31abc4857c526700785e to your computer and use it in GitHub Desktop.
Workflow Tools Engineer Gist for Robert

Workflow Tools Engineer Screener

Thanks again for applying to the Workflow Tools Engineer job at GitHub! The purpose of this gist is to get a better sense of your technical skills and overall communication style.

Engineers at GitHub communicate primarily in written form, via GitHub Issues and Pull Requests. We expect our engineers to communicate clearly and effectively; they should be able to concisely express both their ideas as well as complex technical concepts.

Please complete the following exercise in as much detail as you feel comfortable with. It is purposefully open-ended, and we hope you take the opportunity to show us your familiarity with various technologies, tools, and techniques. Use any resources you'd like. It shouldn't take more than 15 minutes.

Exercise

An engineer has just submitted this new script to a repository of chat commands. The engineer left the following as a description of this new code:

Creates an issue on a given repository from chat. We can now type /issue foobar Banking Customers would like routing numbers highlighted, and an issue will be created on github/foobar with that title. Alternately, you can type /issue foobar 23 Still researching this, and a comment with the text "Still researching this" will be appended to issue 23 in github/foobar.

Spend a few minutes reviewing this code. Remember: you're talking to a person. Please use general comments and/or line comments.

You can leave your commnets in a comment on this gist, or fork it and leave inline comments. If you leave your comments in a comment, prefix line comments with a markdown blockquote of the line you're commenting on, like so:

> require 'bundler/setup'

Everybody hates bundler!

The code:

#!/usr/bin/env ruby

require 'bundler/setup'
require 'octokit'

# I found your example of usage to be a bit misleading. I believe when passing a string as 
# an arguement for ARGV you have to surround it with quotes so it won't be stored as 
# seperate arguements in the ARGV array.
# Maybe something like -- "Usage: /issue REPO [ISSUEID] '<text>' "
# would be more concise.
#
# Also, you built this to create new issues and also add comments to existing issues. 
# It might be best to show examples for each use.
# "Creating a new issue:  /issue REPO '<text>' "
# "Adding a comment to an existing issue:  /issue REPO [ISSUEID] '<text>' "
if ARGV.empty?
  puts "Post new issues or, if given an issue id, add a comment."
  puts "Usage: gh-simple-issue REPO [ISSUEID] <text>"
  exit 1
end

token = ENV['HUBOT_GITHUB_TOKEN']
client = Octokit::Client.new(
  :login        => "hubot",
  :access_token => token
)

repo = issue = nil
if ARGV.length >= 3
  repo = ARGV[0]
  issue = ARGV[1]
  words = ARGV[2]
elsif ARGV.length >= 2
  repo = ARGV[0]
  words = ARGV[1]
end
nwo = "github/#{repo.downcase}"

# The only other possible issue I see is if someone entered only 1 arguement. 
# The variables 'repo' and 'issue' will be set to nil since it wont catch on either 
# of the above if-statements. Then 'nwo' would be set improperly and you would get 
# an error trying to run .downcase on repo (which = nil).
# Then in the code below, issue will be nil so it will run the 'else' statement which 
# won't work as intended with 'nwo' not being equal to the proper repository.
if issue
  client.add_comment(nwo, issue, words)
else
  client.create_issue(nwo, "Opened from #{`hostname -s`.strip} by #{ENV["CAMPFIRE_USER"].strip}", words)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment