...
 
Commits (9)
......@@ -98,6 +98,19 @@ file.
gist -a a.rb
#### Password-less login
If you have a complicated authorization requirement you can manually create a
token file by pasting a Github token with only the `gist` permission into a
file called `~/.gist`. You can create one from https://github.com/settings/tokens
This file should contain only the token (~40 hex characters), and to make it
easier to edit, can optionally have a final newline (\n or \r\n).
For example, one way to create this file would be to run:
echo MY_SECRET_TOKEN > ~/.gist
### GitHub Enterprise
If you'd like `gist` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
......@@ -109,7 +122,7 @@ Once you've done this and restarted your terminal (or run `source ~/.bashrc`), g
automatically use github enterprise instead of the public github.com
Your token for GitHub Enterprise will be stored in `.gist.<protocol>.<server.name>[.<port>]` (e.g.
`~.gist.http.github.internal.example.com` for the GITHUB_URL example above) instead of `~/.gist`.
`~/.gist.http.github.internal.example.com` for the GITHUB_URL example above) instead of `~/.gist`.
If you have multiple servers or use Enterprise and public GitHub often, you can work around this by creating scripts
that set the env var and then run `gist`. Keep in mind that to use the public GitHub you must unset the env var. Just
......
......@@ -47,7 +47,11 @@ Instead of creating a new gist, you can update an existing one by passing its ID
or URL with "-u". For this to work, you must be logged in, and have created the
original gist with the same GitHub account.
Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P] [-f NAME|-t EXT]* FILE*
If you want to skip empty files, use the --skip-empty flag. If all files are
empty no gist will be created.
Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL]
[--skip-empty] [-P] [-f NAME|-t EXT]* FILE*
#{executable_name} --login
#{executable_name} [-l|-r]
......@@ -107,6 +111,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
opts.on("--no-open")
opts.on("--skip-empty", "Skip gisting empty files") do
options[:skip_empty] = true
end
opts.on("-P", "--paste", "Paste from the clipboard to gist") do
options[:paste] = true
end
......@@ -195,7 +203,8 @@ begin
end
end
puts Gist.multi_gist(files, options)
output = Gist.multi_gist(files, options)
puts output if output
end
rescue Gist::Error => e
......
......@@ -1318,7 +1318,7 @@ end
module Gist
extend self
VERSION = '4.6.1'
VERSION = '4.6.2'
# A list of clipboard commands with copy and paste support.
CLIPBOARD_COMMANDS = {
......@@ -1382,10 +1382,14 @@ module Gist
#
# @see http://developer.github.com/v3/gists/
def gist(content, options = {})
filename = options[:filename] || "a.rb"
filename = options[:filename] || default_filename
multi_gist({filename => content}, options)
end
def default_filename
"gistfile1.txt"
end
# Upload a gist to https://gist.github.com
#
# @param [Hash] files the code you'd like to gist: filename => content
......@@ -1398,6 +1402,7 @@ module Gist
# @option options [String] :update the URL or id of a gist to update
# @option options [Boolean] :copy (false) Copy resulting URL to clipboard, if successful.
# @option options [Boolean] :open (false) Open the resulting URL in a browser.
# @option options [Boolean] :skip_empty (false) Skip gisting empty files.
# @option options [Symbol] :output (:all) The type of return value you'd like:
# :html_url gives a String containing the url to the gist in a browser
# :short_url gives a String contianing a git.io url that redirects to html_url
......@@ -1416,10 +1421,16 @@ module Gist
json[:files] = {}
files.each_pair do |(name, content)|
raise "Cannot gist empty files" if content.to_s.strip == ""
json[:files][File.basename(name)] = {:content => content}
if content.to_s.strip == ""
raise "Cannot gist empty files" unless options[:skip_empty]
else
name = name == "-" ? default_filename : File.basename(name)
json[:files][name] = {:content => content}
end
end
return if json[:files].empty? && options[:skip_empty]
existing_gist = options[:update].to_s.split("/").last
if options[:anonymous]
access_token = nil
......@@ -1509,6 +1520,12 @@ module Gist
def read_gist(id, file_name=nil)
url = "#{base_path}/gists/#{id}"
access_token = auth_token()
if access_token.to_s != ''
url << "?access_token=" << CGI.escape(access_token)
end
request = Net::HTTP::Get.new(url)
response = http(api_url, request)
......@@ -1909,7 +1926,11 @@ Instead of creating a new gist, you can update an existing one by passing its ID
or URL with "-u". For this to work, you must be logged in, and have created the
original gist with the same GitHub account.
Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P] [-f NAME|-t EXT]* FILE*
If you want to skip empty files, use the --skip-empty flag. If all files are
empty no gist will be created.
Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL]
[--skip-empty] [-P] [-f NAME|-t EXT]* FILE*
#{executable_name} --login
#{executable_name} [-l|-r]
......@@ -1969,6 +1990,10 @@ Usage: #{executable_name} [-o|-c|-e] [-p] [-s] [-R] [-d DESC] [-a] [-u URL] [-P]
opts.on("--no-open")
opts.on("--skip-empty", "Skip gisting empty files") do
options[:skip_empty] = true
end
opts.on("-P", "--paste", "Paste from the clipboard to gist") do
options[:paste] = true
end
......@@ -2057,7 +2082,8 @@ begin
end
end
puts Gist.multi_gist(files, options)
output = Gist.multi_gist(files, options)
puts output if output
end
rescue Gist::Error => e
......
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIST" "1" "May 2017" "" "Gist manual"
.TH "GIST" "1" "January 2018" "" "Gist manual"
.
.SH "NAME"
\fBgist\fR \- upload code to https://gist\.github\.com
......@@ -149,6 +149,25 @@ gist \-a a\.rb
.
.IP "" 0
.
.P
If you have a complicated authorization requirement you can manually create a token file by pasting a Github token with only the \fBgist\fR permission into a file called \fB~/\.gist\fR\. You can create one from https://github\.com/settings/tokens
.
.P
This file should contain only the token (~40 hex characters), and to make it easier to edit, can optionally have a final newline (\en or \er\en)\.
.
.P
For example, one way to create this file would be to run:
.
.IP "" 4
.
.nf
echo MY_SECRET_TOKEN > ~/\.gist
.
.fi
.
.IP "" 0
.
.SS "GitHub Enterprise"
If you\'d like \fBgist\fR to use your locally installed GitHub Enterprise \fIhttps://enterprise\.github\.com/\fR, you need to export the \fBGITHUB_URL\fR environment variable (usually done in your \fB~/\.bashrc\fR)\.
.
......@@ -166,7 +185,7 @@ export GITHUB_URL=http://github\.internal\.example\.com/
Once you\'ve done this and restarted your terminal (or run \fBsource ~/\.bashrc\fR), gist will automatically use github enterprise instead of the public github\.com
.
.P
Your token for GitHub Enterprise will be stored in \fB\.gist\.<protocol>\.<server\.name>[\.<port>]\fR (e\.g\. \fB~\.gist\.http\.github\.internal\.example\.com\fR for the GITHUB_URL example above) instead of \fB~/\.gist\fR\.
Your token for GitHub Enterprise will be stored in \fB\.gist\.<protocol>\.<server\.name>[\.<port>]\fR (e\.g\. \fB~/\.gist\.http\.github\.internal\.example\.com\fR for the GITHUB_URL example above) instead of \fB~/\.gist\fR\.
.
.P
If you have multiple servers or use Enterprise and public GitHub often, you can work around this by creating scripts that set the env var and then run \fBgist\fR\. Keep in mind that to use the public GitHub you must unset the env var\. Just setting it to the public URL will not work\. Use \fBunset GITHUB_URL\fR
......
gist (4.6.2-1) unstable; urgency=medium
* New upstream version 4.6.2
* Update dh compat to v11
* d/copyright: Update Format URI
* d/control: Update Vcs- URIs to salsa.d.o
* Bump Standards-Version to 4.1.4.1 (no extra changes)
-- Chris Hofstaedtler <zeha@debian.org> Tue, 10 Apr 2018 09:14:33 +0000
gist (4.6.1-1) unstable; urgency=medium
* New upstream version 4.6.1
......
......@@ -2,16 +2,16 @@ Source: gist
Section: net
Priority: optional
Maintainer: Debian Ruby Extras Maintainers <pkg-ruby-extras-maintainers@lists.alioth.debian.org>
Uploaders: Christian Hofstaedtler <zeha@debian.org>
Build-Depends: debhelper (>= 9~),
Uploaders: Chris Hofstaedtler <zeha@debian.org>
Build-Depends: debhelper (>= 11~),
gem2deb,
locales,
rake,
ruby-rspec,
ruby-webmock
Standards-Version: 3.9.8
Vcs-Git: https://anonscm.debian.org/git/pkg-ruby-extras/gist.git
Vcs-Browser: https://anonscm.debian.org/cgit/pkg-ruby-extras/gist.git
Standards-Version: 4.1.4.1
Vcs-Git: https://salsa.debian.org/ruby-team/gist.git
Vcs-Browser: https://salsa.debian.org/ruby-team/gist
Homepage: https://github.com/defunkt/gist
Testsuite: autopkgtest-pkg-ruby
XS-Ruby-Versions: all
......
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gist
Source: https://github.com/defunkt/gist/
......@@ -8,7 +8,7 @@ Copyright: 2012, Conrad Irwin <conrad.irwin@gmail.com>
License: Expat
Files: debian/*
Copyright: 2013 Christian Hofstaedtler <christian@hofstaedtler.name>
Copyright: 2013 Chris Hofstaedtler <zeha@debian.org>
License: Expat
Comment: the Debian packaging is licensed under the same terms as the original package.
......
......@@ -99,18 +99,16 @@ Index: gist/README.md
Obtaining OAuth2 access_token from github.
GitHub username: ConradIrwin
GitHub password:
@@ -96,16 +96,16 @@ file.
@@ -96,7 +96,7 @@ file.
‌After you've done this, you can still upload gists anonymously with `-a`.
- gist -a a.rb
+ gist-paste -a a.rb
### GitHub Enterprise
#### Password-less login
-If you'd like `gist` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
+If you'd like `gist-paste` to use your locally installed [GitHub Enterprise](https://enterprise.github.com/),
you need to export the `GITHUB_URL` environment variable (usually done in your `~/.bashrc`).
@@ -118,7 +118,7 @@ you need to export the `GITHUB_URL` envi
export GITHUB_URL=http://github.internal.example.com/
......@@ -119,7 +117,7 @@ Index: gist/README.md
automatically use github enterprise instead of the public github.com
Your token for GitHub Enterprise will be stored in `.gist.<protocol>.<server.name>[.<port>]` (e.g.
@@ -120,7 +120,7 @@ setting it to the public URL will not wo
@@ -133,7 +133,7 @@ setting it to the public URL will not wo
If you cannot use passwords, as most Enterprise installations do, you can generate the token via the web interface
and then simply save the string in the correct file. Avoid line breaks or you might see:
```
......@@ -128,7 +126,7 @@ Index: gist/README.md
Error: Bad credentials
```
@@ -157,10 +157,10 @@ in `~/.gist`, where it can later be read
@@ -170,12 +170,12 @@ in `~/.gist`, where it can later be read
## Configuration
......@@ -139,9 +137,12 @@ Index: gist/README.md
- alias gist='gist -c'
+ alias gist='gist-paste -c'
‌If you'd prefer gist to open a different browser, then you can export the BROWSER
-‌If you'd prefer gist to open a different browser, then you can export the BROWSER
+‌If you'd prefer gist-paste to open a different browser, then you can export the BROWSER
environment variable:
@@ -171,7 +171,7 @@ If clipboard or browser integration don'
export BROWSER=google-chrome
@@ -184,7 +184,7 @@ If clipboard or browser integration don'
(more ideally) a pull request.
If you need to use an HTTP proxy to access the internet, export the `HTTP_PROXY` or
......
......@@ -12,7 +12,7 @@ end
module Gist
extend self
VERSION = '4.6.1'
VERSION = '4.6.2'
# A list of clipboard commands with copy and paste support.
CLIPBOARD_COMMANDS = {
......@@ -76,10 +76,14 @@ module Gist
#
# @see http://developer.github.com/v3/gists/
def gist(content, options = {})
filename = options[:filename] || "a.rb"
filename = options[:filename] || default_filename
multi_gist({filename => content}, options)
end
def default_filename
"gistfile1.txt"
end
# Upload a gist to https://gist.github.com
#
# @param [Hash] files the code you'd like to gist: filename => content
......@@ -92,6 +96,7 @@ module Gist
# @option options [String] :update the URL or id of a gist to update
# @option options [Boolean] :copy (false) Copy resulting URL to clipboard, if successful.
# @option options [Boolean] :open (false) Open the resulting URL in a browser.
# @option options [Boolean] :skip_empty (false) Skip gisting empty files.
# @option options [Symbol] :output (:all) The type of return value you'd like:
# :html_url gives a String containing the url to the gist in a browser
# :short_url gives a String contianing a git.io url that redirects to html_url
......@@ -110,10 +115,16 @@ module Gist
json[:files] = {}
files.each_pair do |(name, content)|
raise "Cannot gist empty files" if content.to_s.strip == ""
json[:files][File.basename(name)] = {:content => content}
if content.to_s.strip == ""
raise "Cannot gist empty files" unless options[:skip_empty]
else
name = name == "-" ? default_filename : File.basename(name)
json[:files][name] = {:content => content}
end
end
return if json[:files].empty? && options[:skip_empty]
existing_gist = options[:update].to_s.split("/").last
if options[:anonymous]
access_token = nil
......@@ -203,6 +214,12 @@ module Gist
def read_gist(id, file_name=nil)
url = "#{base_path}/gists/#{id}"
access_token = auth_token()
if access_token.to_s != ''
url << "?access_token=" << CGI.escape(access_token)
end
request = Net::HTTP::Get.new(url)
response = http(api_url, request)
......