Skip to content

Commit

Permalink
Merge pull request #33 from samwestmoreland/getrawdiff
Browse files Browse the repository at this point in the history
  • Loading branch information
samwestmoreland authored Nov 20, 2023
2 parents c793f68 + 40d5307 commit 077d857
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
10 changes: 10 additions & 0 deletions differential.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,13 @@ func (c *Conn) DifferentialRevisionEdit(req requests.EditRequest) (*responses.Ed

return &res, nil
}

// DifferentialGetRawDiff performs a call to differential.getrawdiff
func (c *Conn) DifferentialGetRawDiff(req requests.DifferentialGetRawDiffRequest) (*responses.DifferentialGetRawDiffResponse, error) {
var res responses.DifferentialGetRawDiffResponse
if err := c.Call("differential.getrawdiff", &req, &res); err != nil {
return nil, err
}

return &res, nil
}
6 changes: 5 additions & 1 deletion entities/differential.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ type DifferentialHunk struct {
Corpus string `json:"corpus"`
}

// A DifferentialRawDiff is a raw diff.
type DifferentialRawDiff struct {
Diff string `json:"diff"`
}

// DifferentialDiffUpdateTransaction adds a diff (by PHID) to the given revision
func DifferentialDiffUpdateTransaction(diff PHID) Transaction {
Expand Down Expand Up @@ -324,4 +328,4 @@ func DifferentialSetSubscribersTransaction(subscribers []PHID) Transaction {
Type: "subscribers.set",
Value: subscribers,
}
}
}
7 changes: 7 additions & 0 deletions requests/differential_getrawdiff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package requests

// DifferentialGetRawDiffRequest represents a request to differential.getrawdiff.
type DifferentialGetRawDiffRequest struct {
DiffID string `json:"diffID"`
Request
}
6 changes: 6 additions & 0 deletions responses/differential_getrawdiff.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package responses

import "github.com/thought-machine/gonduit/entities"

// DifferentialGetRawDiffResponse is the response from calling differential.getrawdiff.
type DifferentialGetRawDiffResponse *entities.DifferentialRawDiff
8 changes: 4 additions & 4 deletions test/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func New() *Server {
func (s *Server) RegisterCapabilities() {
s.RegisterMethod("conduit.getcapabilities", 200, gin.H{
"result": map[string][]string{
"authentication": []string{"token", "session"},
"signatures": []string{"consign"},
"input": []string{"json", "urlencoded"},
"output": []string{"json"},
"authentication": {"token", "session"},
"signatures": {"consign"},
"input": {"json", "urlencoded"},
"output": {"json"},
},
})
}
Expand Down

0 comments on commit 077d857

Please sign in to comment.