| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | |
| 3 // that can be found in the LICENSE file. | |
| 4 | |
| 5 package model | |
| 6 | |
| 7 import ( | |
| 8 ds "github.com/luci/gae/service/datastore" | |
| 9 | |
| 10 "golang.org/x/net/context" | |
| 11 ) | |
| 12 | |
| 13 // Repository represents a repository that a Revision belongs to. | |
| 14 type Repository struct { | |
| 15 ds.Key | |
| 16 } | |
| 17 | |
| 18 // GetRepository returns the repository object for a given repository URL. | |
| 19 // TODO(martiniss): convert this to luci project name by 2016-01 | |
| 20 func GetRepository(c context.Context, repositoryURL string) *Repository { | |
| 21 return &Repository{ | |
| 22 *ds.NewKey(c, "Repository", repositoryURL, 0, nil), | |
| 23 } | |
| 24 } | |
| 25 | |
| 26 // GetRevision returns the corresponding Revision object for a particular | |
| 27 // revision hash in this repository. | |
| 28 func (r *Repository) GetRevision(c context.Context, digest string) (*Revision, e
rror) { | |
| 29 rev := &Revision{ | |
| 30 Digest: digest, | |
| 31 Repository: &r.Key, | |
| 32 } | |
| 33 | |
| 34 err := ds.Get(c, rev) | |
| 35 return rev, err | |
| 36 } | |
| 37 | |
| 38 // RevisionMetadata is the metadata associated with a particular Revision. | |
| 39 type RevisionMetadata struct { | |
| 40 // Message is the commit message for a Revision. | |
| 41 Message string | |
| 42 } | |
| 43 | |
| 44 // Revision is a immutable reference to a version of the code in a given | |
| 45 // repository at a given point in time. | |
| 46 // | |
| 47 // Note that currently revisions have no notion of branch. This will need to | |
| 48 // change once we support Chromium. | |
| 49 type Revision struct { | |
| 50 // Digest is the content hash which uniquely identifies this Revision, i
n the | |
| 51 // context of its repository. | |
| 52 Digest string `gae:"$id"` | |
| 53 | |
| 54 // Repository is the repository this Revision is associated with. See th
e | |
| 55 // Repository struct for more info. | |
| 56 Repository *ds.Key `gae:"$parent"` | |
| 57 | |
| 58 // Metadata is any metadata (commit message, files changed, etc.) | |
| 59 // associated with this Revision. | |
| 60 Metadata RevisionMetadata `gae:",noindex"` | |
| 61 | |
| 62 // Committer is the email of the user who committed this change. | |
| 63 Committer string | |
| 64 | |
| 65 // Generation is the generation number of this Revision. This is used to
sort | |
| 66 // commits into a roughly time-based order, without using timestamps. | |
| 67 // See http://www.spinics.net/lists/git/msg161165.html for background. | |
| 68 Generation int | |
| 69 } | |
| OLD | NEW |