Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* use github username and token from shell environment if it exists there. If not, check git config
- Loading branch information
Showing
4 changed files
with
69 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'net/http' | ||
require 'uri' | ||
|
||
git_binary = ENV['TM_GIT'] || "/usr/bin/env git" | ||
github_config_get = "#{git_binary} config --global --get github" | ||
|
||
@login = ENV['GITHUB_USER'] || `#{github_config_get}.user`.chomp | ||
@token = ENV['GITHUB_TOKEN'] || `#{github_config_get}.token`.chomp | ||
|
||
@continue = true | ||
|
||
if @login.nil? || @login == '' | ||
print "\nError: your github login is not set. See https://github.com/ivanvc/gists-tmbundle for configuration instructions.\n" | ||
@continue = false | ||
end | ||
if @token.nil? || @token == '' | ||
print "\nError: your github token is not set. See https://github.com/ivanvc/gists-tmbundle for configuration instructions.\n" | ||
@continue = false | ||
end | ||
|
||
@contents = ENV['TM_SELECTED_TEXT'] || `/usr/bin/env cat "#{ENV['TM_FILEPATH']}"` | ||
@name = ENV['TM_FILENAME'] || 'Uploaded from TextMate' | ||
|
||
if @contents.nil? || @contents.strip == '' | ||
puts "Error: no content to upload" | ||
@continue = false | ||
end |