Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(902)

Side by Side Diff: go/src/infra/libs/gitiles/priv_jsonCommitDiff.go

Issue 662113003: Drover's back, baby! (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git/+/master
Patch Set: more tests and refactors Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « go/src/infra/libs/gitiles/gitiles.go ('k') | go/src/infra/libs/gitiles/priv_jsonRequest.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package gitiles
6
7 import (
8 "infra/libs/git"
9 "strings"
10 )
11
12 // Private /////////////////////////////////////////////////////////////////////
13
14 // Types ///////////////////////////////////////////////////////////////////////
15
16 type jsonCommitDiff struct {
17 TreeDiff []struct {
18 Type string `json:"type"`
19 OldID string `json:"old_id"`
20 OldMode git.Mode `json:"old_mode"`
21 OldPath string `json:"old_path"`
22 NewID string `json:"new_id"`
23 NewMode git.Mode `json:"new_mode"`
24 NewPath string `json:"new_path"`
25 } `json:"tree_diff"`
26 }
27
28 // Member functions ////////////////////////////////////////////////////////////
29
30 func (c *jsonCommitDiff) ToResult() (git.TreeDiff, error) {
31 td := make(git.TreeDiff, 0, len(c.TreeDiff))
32 for _, ent := range c.TreeDiff {
33 oldID, err := git.MakeObjectIDErr(ent.OldID)
34 if err != nil {
35 return nil, err
36 }
37 newID, err := git.MakeObjectIDErr(ent.NewID)
38 if err != nil {
39 return nil, err
40 }
41 oldChild, err := git.NewEmptyChild(ent.OldMode, oldID)
42 if err != nil {
43 return nil, err
44 }
45 newChild, err := git.NewEmptyChild(ent.NewMode, newID)
46 if err != nil {
47 return nil, err
48 }
49
50 td = append(td, git.TreeDiffEntry{
51 Action: strings.ToUpper(ent.Type[:1]),
52 Old: git.TreeDiffEntryHalf{
53 Child: *oldChild,
54 Name: ent.OldPath,
55 },
56 New: git.TreeDiffEntryHalf{
57 Child: *newChild,
58 Name: ent.NewPath,
59 },
60 })
61 }
62 return td, nil
63 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/gitiles/gitiles.go ('k') | go/src/infra/libs/gitiles/priv_jsonRequest.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698