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

Issue 662113003: Drover's back, baby! (Closed)

Created:
6 years, 2 months ago by iannucci
Modified:
4 years, 7 months ago
Reviewers:
agable, M-A Ruel
CC:
chromium-reviews
Base URL:
https://chromium.googlesource.com/infra/infra.git/+/master
Project:
infra
Visibility:
Public.

Description

Drover's back, baby! Implements drover for git! Assumes some things about the git repo though: * uses cr-rev to disambiguate commit-to-land * includes automatic discovery of git repo * uses gitiles to fetch the minimal subset of objects necessary for the specified action. * knows about codereview.settings and the pending ref stuff. Features: * Colors * Progress bars * It's really really fast * Performs the action in a real on-disk environment with real (minimal) git commits. No history is available, but if there's a conflict, you can resolve it in the normal way. * Pops you into a shell in the directory if it detects a conflict. * Currently stops short of the push, but I've verified that the git client can correctly synthesize the packfile and perform the push. * Intermediate progress is cached locally... if something goes sideways in the process you can re-do the command and it will only fetch objects it doesn't have yet. * Probably works on windows (untested) R=agable@chromium.org,maruel@chromium.org BUG=404755

Patch Set 1 #

Total comments: 88

Patch Set 2 : Lots of fixes #

Total comments: 84

Patch Set 3 : add some tests, do some refactors #

Patch Set 4 : More tests and switch to goconvey assertions #

Patch Set 5 : more tests and refactors #

Unified diffs Side-by-side diffs Delta from patch set Stats (+4042 lines, -15 lines) Patch
M go/src/infra/hello_pkg/hello_pkg.go View 1 1 chunk +3 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/blob.go View 1 2 3 4 1 chunk +40 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/blob_test.go View 1 2 3 4 1 chunk +49 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/child.go View 1 2 3 4 1 chunk +34 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/child_test.go View 1 2 3 4 1 chunk +24 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/commit.go View 1 2 3 4 1 chunk +242 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/commit_test.go View 1 2 3 4 1 chunk +163 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/emptyObject.go View 1 2 3 4 1 chunk +54 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/emptyObject_test.go View 1 2 3 4 1 chunk +30 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/git.goconvey View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
A go/src/infra/libs/git/mode.go View 1 2 3 1 chunk +32 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/mode_test.go View 1 2 3 1 chunk +35 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/object.go View 1 2 3 4 1 chunk +57 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/objectID.go View 1 2 1 chunk +90 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/objectID_test.go View 1 2 3 1 chunk +43 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/objectType.go View 1 2 1 chunk +57 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/objectType_test.go View 1 2 3 1 chunk +40 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/object_test.go View 1 2 3 4 1 chunk +88 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/repo/repo.go View 1 2 3 4 1 chunk +345 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/repo/repo_test.go View 1 2 1 chunk +23 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/tree.go View 1 2 3 4 1 chunk +424 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/treeDiff.go View 1 2 3 1 chunk +44 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/tree_test.go View 1 2 3 4 1 chunk +558 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/types.go View 1 2 3 4 1 chunk +63 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/user.go View 1 2 1 chunk +68 lines, -0 lines 0 comments Download
A go/src/infra/libs/git/user_test.go View 1 2 3 1 chunk +48 lines, -0 lines 0 comments Download
A go/src/infra/libs/gitiles/gitiles.go View 1 2 1 chunk +155 lines, -0 lines 0 comments Download
A go/src/infra/libs/gitiles/priv_jsonCommitDiff.go View 1 2 3 4 1 chunk +63 lines, -0 lines 0 comments Download
A go/src/infra/libs/gitiles/priv_jsonRequest.go View 1 2 1 chunk +61 lines, -0 lines 0 comments Download
A go/src/infra/libs/gitiles/priv_objRequest.go View 1 2 1 chunk +52 lines, -0 lines 0 comments Download
A go/src/infra/libs/gitiles/priv_textRequest.go View 1 2 1 chunk +47 lines, -0 lines 0 comments Download
A go/src/infra/libs/gitiles/statusError.go View 1 2 1 chunk +18 lines, -0 lines 0 comments Download
A go/src/infra/libs/infra_util/buf.go View 1 2 1 chunk +41 lines, -0 lines 0 comments Download
A go/src/infra/libs/infra_util/errors.go View 1 2 3 4 1 chunk +71 lines, -0 lines 0 comments Download
A go/src/infra/libs/infra_util/stringSet.go View 1 2 3 4 1 chunk +60 lines, -0 lines 0 comments Download
A go/src/infra/libs/infra_util/test_utils.go View 1 2 1 chunk +25 lines, -0 lines 0 comments Download
A + go/src/infra/tools/drover/default_shell_darwin.go View 1 1 chunk +2 lines, -5 lines 0 comments Download
A + go/src/infra/tools/drover/default_shell_linux.go View 1 1 chunk +2 lines, -5 lines 0 comments Download
A + go/src/infra/tools/drover/default_shell_windows.go View 1 1 chunk +2 lines, -5 lines 0 comments Download
A go/src/infra/tools/drover/disambiguate.go View 1 1 chunk +167 lines, -0 lines 0 comments Download
A go/src/infra/tools/drover/main.go View 1 2 1 chunk +215 lines, -0 lines 0 comments Download
A go/src/infra/tools/drover/merge.go View 1 2 3 4 1 chunk +366 lines, -0 lines 0 comments Download
A go/src/infra/tools/drover/util.go View 1 1 chunk +40 lines, -0 lines 0 comments Download

Messages

Total messages: 10 (2 generated)
iannucci
Needs tests, and needs a couple packages mirrored (for progress bar and colors), but totally ...
6 years, 2 months ago (2014-10-17 23:29:07 UTC) #1
iannucci
And please suggest API refactoring... I posted this all in one chunk, but I think ...
6 years, 2 months ago (2014-10-17 23:36:58 UTC) #2
M-A Ruel
Also a package level comment on each non-main package would be nice. https://codereview.chromium.org/662113003/diff/1/go/src/infra/libs/git/blob.go File go/src/infra/libs/git/blob.go ...
6 years, 2 months ago (2014-10-18 00:47:07 UTC) #3
iannucci
+vadimsh lots of fixes, PTAL https://codereview.chromium.org/662113003/diff/1/go/src/infra/libs/git/blob.go File go/src/infra/libs/git/blob.go (right): https://codereview.chromium.org/662113003/diff/1/go/src/infra/libs/git/blob.go#newcode1 go/src/infra/libs/git/blob.go:1: package git On 2014/10/18 ...
6 years, 2 months ago (2014-10-20 21:11:58 UTC) #5
M-A Ruel
I think it's enough comments for now. :) https://codereview.chromium.org/662113003/diff/1/go/src/infra/libs/git/commit.go File go/src/infra/libs/git/commit.go (right): https://codereview.chromium.org/662113003/diff/1/go/src/infra/libs/git/commit.go#newcode27 go/src/infra/libs/git/commit.go:27: return ...
6 years, 2 months ago (2014-10-21 00:55:55 UTC) #6
Vadim Sh.
I don't know go and don't know git internals, so do not mind my review ...
6 years, 2 months ago (2014-10-21 15:27:00 UTC) #7
agable
Didn't make it through all of this (sick today :() but here are some initial ...
6 years, 2 months ago (2014-10-21 17:01:35 UTC) #8
iannucci
4 years, 7 months ago (2016-05-23 21:53:43 UTC) #10
Message was sent while issue was closed.
sending comments for historical purposes; this CL is dead.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/bl...
File go/src/infra/libs/git/blob.go (right):

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/bl...
go/src/infra/libs/git/blob.go:4: package git
On 2014/10/21 00:55:53, M-A Ruel wrote:
> you need to keep an empty line, otherwise it is considered package
> documentation. You can confirm with godoc -http=:6060

oh, yikes, ok

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/bl...
go/src/infra/libs/git/blob.go:9: data string
On 2014/10/21 00:55:53, M-A Ruel wrote:
> So you really use string here as []byte. I think I'd prefer []byte. String has
> implication that it is somehow human readable.

Well... most blobs /are/ human readable (usually text files). The other
advantage is that string is immutable but []byte is not, which means one less
copy.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/bl...
go/src/infra/libs/git/blob.go:22: // BlobFromRawWithID creates a new *Blob,
trusting |id|. There is no verification
On 2014/10/21 00:55:53, M-A Ruel wrote:
> Generally I personally ensure these docstrings are 80 cols.

Done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
File go/src/infra/libs/git/commit.go (right):

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:33: u.Time.Format("-0700"))
On 2014/10/21 00:55:53, M-A Ruel wrote:
> Either use the local time or UTC, but do not hardcode the time zone.

Again, it's not hard coded :) Read Time.Format docs:
http://golang.org/pkg/time/#Time.Format

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:86: func (c *Commit) SetTree(t ObjectID) (ret
*Commit) {
On 2014/10/21 00:55:53, M-A Ruel wrote:
> That still means that SetTree() modifies the caller if it was not set. I think
> it's unexpected behavior.

It modifies the caller only if the caller started with a partial commit (e.g.
wasn't hashed, so id == NoID).

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:211: // Parses the message for footer_pairs,
footers, message_lines
On 2014/10/21 00:55:53, M-A Ruel wrote:
> parseMessage parses ...

Done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:214: i := -1
On 2014/10/21 00:55:54, M-A Ruel wrote:
> i := len(allLines)

Done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:215: for i = len(allLines) - 1; i >= 0; i-- {
On 2014/10/21 00:55:53, M-A Ruel wrote:
> for ; i>= 0; i-- {

Done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:234: key, value := bits[0], bits[1]
On 2014/10/21 00:55:53, M-A Ruel wrote:
> This will crash if there was no ": "

yep, which is impossible due to line 219.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/co...
go/src/infra/libs/git/commit.go:266: t, err := time.Parse("-0700", fields[5])
On 2014/10/21 00:55:54, M-A Ruel wrote:
> I'm not a big fan of named return value. This line is a good example, where
it's
> ambiguous if err is being aliased or not. I'd recommend against.

Done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/ob...
File go/src/infra/libs/git/object.go (right):

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/ob...
go/src/infra/libs/git/object.go:18: TreeType
On 2014/10/21 00:55:54, M-A Ruel wrote:
> Y U NO TAG? Even if you explicitly do not support it, it's worth stating this
> explicitly.

Omission, though "tag" doesn't show up in tree objects. I added it anyway, since
trees explicitly scope to just {Commit, Blob, Tree} types, and it could show up
in a cat-file request.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/ob...
go/src/infra/libs/git/object.go:69: type ObjectID struct {
On 2014/10/21 00:55:54, M-A Ruel wrote:
> It's fine and shorter to use 
> type ObjectID [20] byte
> 
> iif you want. I don't mind.

Modifiable, and I can't have a type alias whose 'real' type is private to the
package :(

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
File go/src/infra/libs/git/repo.go (right):

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
go/src/infra/libs/git/repo.go:24: NoBlobs           = false
On 2014/10/21 00:55:54, M-A Ruel wrote:
> If the type is not exported, the consts should not be exported either.

Why not? I don't want them constructing their own flavor of it (e.g. I can
reserve the right to change the underlying type), but let them use the constant
values. That seems reasonable to me, but maybe I'm missing something?

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
go/src/infra/libs/git/repo.go:50: // Actino is one of "ACDMRTUX"
On 2014/10/21 00:55:54, M-A Ruel wrote:
> Action

oops. done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
go/src/infra/libs/git/repo.go:82: RawString() string
On 2014/10/21 00:55:54, M-A Ruel wrote:
> As with the other part, I think []byte is a bit more appropriate, which would
> mean renaming the function. :)

but then I have to copy all that data or ppl could modify the underlying stuff
:(

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
go/src/infra/libs/git/repo.go:87: func (r *Repo) RunInput(input string, cmd
...string) (string, bool) {
On 2014/10/21 00:55:54, M-A Ruel wrote:
> That's an example of a function that could accept a Repo as a parameter.

I'm not sure why that would be helpful though, since it's also never useful
/without/ a Repo.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
go/src/infra/libs/git/repo.go:161: // HasObject will return true iff the Repo
contains the objectish
On 2014/10/21 00:55:54, M-A Ruel wrote:
> objectish or ref?

objectish. could be a hash, ref, hash:path/to/file, ref~2, etc.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/re...
go/src/infra/libs/git/repo.go:172: func (r *Repo) HasObjectID(id ObjectID) bool
{
On 2014/10/21 00:55:54, M-A Ruel wrote:
> What about just this function and not have HasObject()? It's much clearer
IMHO.

It is, but it's less powerful.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/tr...
File go/src/infra/libs/git/tree.go (right):

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/tr...
go/src/infra/libs/git/tree.go:65: func (t *Tree) ID() ObjectID { return t.id }
On 2014/10/21 00:55:55, M-A Ruel wrote:
> Why not call Rehash automatically?

Because if it's an empty tree, rehashing it would cause it to obliterate the ID
information (and replace it with the ID of an empty tree).

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/tr...
go/src/infra/libs/git/tree.go:126: // TreeFromText returns a Complete() Tree for
a `git ls-tree`-formatted
On 2014/10/21 00:55:55, M-A Ruel wrote:
> Note that there could be cases where it doesn't fit in memory.

The thought crossed my mind, but for now I think it's OK. In practice, we don't
have any trees which even approach a megabyte (the /recursive/ enumeration of
blink's LayoutTests directory is 11MB).

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/tr...
go/src/infra/libs/git/tree.go:258: if t.cachedRawString == nil {
On 2014/10/21 00:55:55, M-A Ruel wrote:
> It's not necessary that it is a pointer, because it can't be "" and still be
> valid, so you can do instead:
> 
> if t.cachedRawString == "" {
>   ...
> 
> and not use a pointer.

Except that it /can/ be "" :).

$ git hash-object --stdin -t tree < /dev/null
4b825dc642cb6eb9a060e54bf8d69288fbee4904

tah-dah!

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/tr...
go/src/infra/libs/git/tree.go:282: /// Private
On 2014/10/21 00:55:54, M-A Ruel wrote:
> assuming is a file block section, add an empty line.

Done.

https://codereview.chromium.org/662113003/diff/20001/go/src/infra/libs/git/tr...
go/src/infra/libs/git/tree.go:341: r.Intern(t)
On 2014/10/21 00:55:55, M-A Ruel wrote:
> What about a directory containing a directory that is empty?

It's not a standard thing in git. You can contrive a tree object containing an
entry with an empty tree, but by default git will not produce such a thing.
Hence the existence of .gitkeep files.

Powered by Google App Engine
This is Rietveld 408576698