- Notifications
You must be signed in to change notification settings - Fork 148
API extensions #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
API extensions #12
Changes from all commits
Commits
Show all changes
13 commits Select commit Hold shift + click to select a range
fd43787
repo commits client and repo releases client
kiliit 1a3306e
removed unnecessary fields
kiliit 0bfe8f9
some fixes
kiliit 7cc97a8
git diff models
kiliit 9f510d0
changed file and line type to strings
kiliit 463f6d1
changed commit HEAD to use Sha1 type
kiliit 1492ebf
create user api
kiliit dd053eb
Merge remote-tracking branch 'origin/develop'
kiliit 6365a78
fork options
kiliit 47a4752
remove private option from fork
kiliit 20d5208
started collab
kiliit b207243
merged with upstream
kiliit 6c32f56
url stuff
kiliit File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
| @@ -22,3 +22,5 @@ _testmain.go | |
*.exe | ||
*.test | ||
*.prof | ||
| ||
*iml |
This file contains hidden or 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 hidden or 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,62 @@ | ||
// Copyright 2014 The Gogs Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
| ||
package gogs | ||
| ||
import ( | ||
"fmt" | ||
"time" | ||
) | ||
| ||
type Sha1 struct { | ||
Sha1 string `json:"sha1"` | ||
} | ||
| ||
type Signature struct { | ||
Email string `json:"email"` | ||
Name string `json:"name"` | ||
When time.Time `json:"when"` | ||
} | ||
| ||
type Commit struct { | ||
ID string `json:"id"` | ||
Author Signature `json:"author"` | ||
Committer Signature `json:"committer"` | ||
CommitMessage string `json:"commit_message"` | ||
} | ||
| ||
type DiffLine struct { | ||
LeftIdx int `json:"left_idx"` | ||
RightIdx int `json:"right_idx"` | ||
Type string `json:"type"` | ||
Content string `json:"content"` | ||
} | ||
| ||
type DiffSection struct { | ||
Name string `json:"name"` | ||
Lines []*DiffLine `json:"lines"` | ||
} | ||
| ||
type DiffFile struct { | ||
Name string `json:"name"` | ||
Index int `json:"index"` | ||
Addition int `json:"addition"` | ||
Deletion int `json:"deletion"` | ||
Type string `json:"type"` | ||
IsCreated bool `json:"created"` | ||
IsDeleted bool `json:"deleted"` | ||
IsBin bool `json:"bin"` | ||
Sections []*DiffSection `json:"sections"` | ||
} | ||
| ||
type Diff struct { | ||
TotalAddition int `json:"total_addition"` | ||
TotalDeletion int `json:"total_deletion"` | ||
Files []*DiffFile `json:"files"` | ||
} | ||
| ||
func (c *Client) CommitByID(user, repo, id string) (*Commit, error) { | ||
commit := new(Commit) | ||
return commit, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/commits/%s", user, repo, id), nil, nil, commit) | ||
} |
This file contains hidden or 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,60 @@ | ||
// Copyright 2014 The Gogs Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
| ||
package gogs | ||
| ||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
"time" | ||
) | ||
| ||
type Release struct { | ||
ID int64 `json:"id"` | ||
Publisher User `json:"publisher"` | ||
TagName string `json:"tag_name"` | ||
LowerTagName string `json:"lower_tag_name"` | ||
Target string `json:"target"` | ||
Title string `json:"title"` | ||
Sha1 string `json:"sha1"` | ||
NumCommits int `json:"num_commits"` | ||
NumCommitsBehind int `json:"num_commits_behind"` | ||
Note string `json:"note"` | ||
IsDraft bool `json:"draft"` | ||
IsPrerelease bool `json:"prerelease"` | ||
Created time.Time `json:"created"` | ||
} | ||
| ||
func (c *Client) ReleaseByName(user, repo, name string) (*Release, error) { | ||
release := new(Release) | ||
return release, c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/releases/%s", user, repo, name), nil, nil, release) | ||
} | ||
| ||
func (c *Client) ListReleases() ([]*Release, error) { | ||
releases := make([]*Release, 0, 10) | ||
err := c.getParsedResponse("GET", "/repos/%s/%s/releases", nil, nil, &releases) | ||
return releases, err | ||
} | ||
| ||
type CreateReleaseOption struct { | ||
TagName string `json:"tag_name"` | ||
Target string `json:"target"` | ||
Title string `json:"title"` | ||
Note string `json:"note"` | ||
IsDraft bool `json:"draft"` | ||
IsPrerelease bool `json:"prerelease"` | ||
} | ||
| ||
| ||
func (c *Client) CreateRelease(user string, repo string, opt CreateReleaseOption) (*Release, error) { | ||
body, err := json.Marshal(&opt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
release := new(Release) | ||
return release, c.getParsedResponse("POST", fmt.Sprintf("/repos/%s/%s/releases", user, repo), | ||
http.Header{"content-type": []string{"application/json"}}, bytes.NewReader(body), release) | ||
} |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this struct do? Seems not using it anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I didn't create the client method in the gogs client.
The DiffFile struct is used in gogs.
I tested the service method from the java lib and forgot the client method in gogs-client
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK... should you remove it or...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. It is used by Gogs, and is needed for my gogs pull request. See the DiffRange function in the that pull request.
This is also why the gogs pull request has dependency to kiliit/go-gogs-client. If it hasn't then compile fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I don't get it...
Gogs has these structs itself, why need import from this package?