Skip to content

Commit 3c693ad

Browse files
committed
github: remove unused functions
I doubt anyone is using this client, and if they are, they can switch.
1 parent 5ee0a77 commit 3c693ad

3 files changed

Lines changed: 0 additions & 95 deletions

File tree

github-release.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import (
88
"github.com/voxelbrain/goptions"
99
)
1010

11-
const GH_URL = "https://github.com"
12-
1311
type Options struct {
1412
Help goptions.Help `goptions:"-h, --help, description='Show this help'"`
1513
Verbosity []bool `goptions:"-v, --verbose, description='Be verbose'"`

github/file.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
package github
22

33
import (
4-
"bytes"
5-
"errors"
64
"fmt"
7-
"io"
85
"os"
96
)
107

@@ -44,36 +41,3 @@ func fsizeSeek(f *os.File) (int64, error) {
4441
}
4542
return off, nil
4643
}
47-
48-
// materializeFile takes a physical file or stream (named pipe, user input,
49-
// ...) and returns an io.Reader and the number of bytes that can be read
50-
// from it.
51-
func materializeFile(f *os.File) (io.Reader, int64, error) {
52-
fi, err := f.Stat()
53-
if err != nil {
54-
return nil, 0, err
55-
}
56-
57-
// If the file is actually a char device (like user typed input)
58-
// or a named pipe (like a streamed in file), buffer it up.
59-
//
60-
// When uploading a file, you need to either explicitly set the
61-
// Content-Length header or send a chunked request. Since the
62-
// github upload server doesn't accept chunked encoding, we have
63-
// to set the size of the file manually. Since a stream doesn't have a
64-
// predefined length, it's read entirely into a byte buffer.
65-
if fi.Mode()&(os.ModeCharDevice|os.ModeNamedPipe) == 1 {
66-
vprintln("input was a stream, buffering up")
67-
68-
var buf bytes.Buffer
69-
n, err := buf.ReadFrom(f)
70-
if err != nil {
71-
return nil, 0, errors.New("req: could not buffer up input stream: " + err.Error())
72-
}
73-
return &buf, n, err
74-
}
75-
76-
// We know the os.File is most likely an actual file now.
77-
n, err := GetFileSize(f)
78-
return f, n, err
79-
}

github/github.go

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ const DefaultBaseURL = "https://api.github.com"
1919
// Set to values > 0 to control verbosity, for debugging.
2020
var VERBOSITY = 0
2121

22-
// DoAuthRequest ...
23-
//
24-
// TODO: This function is amazingly ugly (separate headers, token, no API
25-
// URL constructions, et cetera).
26-
func DoAuthRequest(method, url, mime, token string, headers map[string]string, body io.Reader) (*http.Response, error) {
27-
req, err := newAuthRequest(method, url, mime, token, headers, body)
28-
if err != nil {
29-
return nil, err
30-
}
31-
32-
resp, err := http.DefaultClient.Do(req)
33-
if err != nil {
34-
return nil, err
35-
}
36-
37-
return resp, nil
38-
}
39-
4022
// Client collects a few options that can be set when contacting the GitHub
4123
// API, such as authorization tokens. Methods called on Client will supply
4224
// these options when calling the API.
@@ -227,45 +209,6 @@ func (c Client) getPaginated(uri string) (io.ReadCloser, error) {
227209
return r, nil
228210
}
229211

230-
// Create a new request that sends the auth token.
231-
func newAuthRequest(method, url, mime, token string, headers map[string]string, body io.Reader) (*http.Request, error) {
232-
vprintln("creating request:", method, url, mime, token)
233-
234-
var n int64 // content length
235-
var err error
236-
if f, ok := body.(*os.File); ok {
237-
// Retrieve the content-length and buffer up if necessary.
238-
body, n, err = materializeFile(f)
239-
if err != nil {
240-
return nil, err
241-
}
242-
}
243-
244-
req, err := http.NewRequest(method, url, body)
245-
if err != nil {
246-
return nil, err
247-
}
248-
249-
// net/http automatically does this if req.Body is of type
250-
// (bytes.Reader|bytes.Buffer|strings.Reader). Sadly, we also need to
251-
// handle *os.File.
252-
if n != 0 {
253-
vprintln("setting content-length to", n)
254-
req.ContentLength = n
255-
}
256-
257-
if mime != "" {
258-
req.Header.Set("Content-Type", mime)
259-
}
260-
req.Header.Set("Authorization", "token "+token)
261-
262-
for k, v := range headers {
263-
req.Header.Set(k, v)
264-
}
265-
266-
return req, nil
267-
}
268-
269212
// nextLink returns the HTTP header Link annotated with 'next', "" otherwise.
270213
func nextLink(links linkheader.Links) string {
271214
for _, link := range links {

0 commit comments

Comments
 (0)