Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
podviaznikov committed Nov 27, 2011
1 parent 96625b5 commit 04af3d3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
3 changes: 1 addition & 2 deletions lib/massive.git.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,7 @@ MassiveGit = exports.MassiveGit = class MassiveGit
entries = tree.entries
treeEntries = []
for blob in blobs
blobId = blob.id()
name = entry.name for entry in entries when entry.id == blobId
name = entry.name for entry in entries when entry.id == blob.id()
treeEntries.push new TreeEntry name, blob
callback err, treeEntries

Expand Down
2 changes: 1 addition & 1 deletion lib/objects/git.entity.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ GitEntity = exports.GitEntity = class GitEntity
# Method for building link.
buildLink: (bucket, key, tag) -> utils.buildLink bucket, key, tag

# Method that check whether two `GitEntities` are the same.
# Method checks whether two `GitEntities` are the same.
equals: (gitEntity) =>
@id() == gitEntity.id() and _.isEqual(@links(), gitEntity.links()) and _.isEqual(@attributes(), gitEntity.attributes())

5 changes: 1 addition & 4 deletions lib/objects/git.object.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
crypto = require "crypto"
GitEntity = require("./git.entity").GitEntity

sha1 = (data) ->
shasum = crypto.createHash "sha1"
shasum.update data
shasum.digest "hex"
sha1 = (data) -> crypto.createHash("sha1").update(data).digest("hex")

# GitObject
# ------------
Expand Down
19 changes: 7 additions & 12 deletions lib/objects/repo.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ GitEntity = require("./git.entity").GitEntity
# Class representing repository.
# `id` - unique repository id. Id calculated from `owner`, `type` and `name` of the repository.
# `author` - repository's author.
# `type` - type of the repository. Metainformation.
# `type` - type of the repository. Meta information.
# `public` - flag that indicated whether repo is public or private. Default to `true`.
# `commit` - last commit for this repository. Can be `null` if repository wasn't commited previously.
# `forkedFrom` - id of the repository from which this was cloned. Default to `null`.
# todo (anton) repo type can be stored as secondary index.
Repo = exports.Repo = class Repo extends GitEntity

constructor: (@name, @author, @type, @public = true, @commit, @forkedFrom = null) ->
Expand All @@ -24,25 +23,21 @@ Repo = exports.Repo = class Repo extends GitEntity

# Method for getting plain `attributes` of the GitObject.
attributes: =>
# TODO (Anton) why we have `attributes` key here
attributes =
name : @name
type : @type
public: @public
name : @name
type : @type
public: @public

# Method for getting `index`es of the GitObject.
index: =>
author: @author
type : @type
public: @public

# Method for getting `links` that connect this GitObject with another GitObjects, users or repositories.
# Method for getting `links` that connect this GitObject with other Git Objects, users or repositories.
links: =>
links = []
links.push @buildLink "users", @author, "author"
if(@forkedFrom)
links.push @buildLink "repositories", @forkedFrom, "forked_from"
if(@commit)
links.push @buildLink "objects", @commit, "commit"
links.push @buildLink "repositories", @forkedFrom, "forked_from" if @forkedFrom
links.push @buildLink "objects", @commit, "commit" if @commit
links

3 changes: 1 addition & 2 deletions lib/objects/tree.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
_ = require "underscore"
GitObject = require("./git.object").GitObject


# Tree
# ---------
# Tree is one of the 4 core Git Objects. Tree stores `entries` which are links to blobs and other trees.
Expand All @@ -24,7 +23,7 @@ Tree = exports.Tree = class Tree extends GitObject
# Method for getting plain `attributes` of the GitObject.
attributes: =>
attributes = super()
# todo (anton) we need to store entities also here. Since they cannot be fully repopulated from links (mode and name of entry).
# @NOTE (anton) we need to store entities also here. Since they cannot be fully repopulated from links (mode and name of entry).
# However for now it's not clear do we need these 'full' entities...
attributes.entries = @entries
attributes
Expand Down
7 changes: 3 additions & 4 deletions lib/objects/utils.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ utils = exports
# Method for finding appropriate link `key` by `tag` name.
# Return `null` if link wasn't found.
utils.getLink = (links, tagName) ->
link =_.detect links, (link) -> tagName == link.tag
if(link)
link = _.detect links, (link) -> tagName == link.tag
if link
return link.key
else
return null
Expand All @@ -16,8 +16,7 @@ utils.getLinks = (links, tagName) ->
_.map filtered, (link) -> link.key

# Utility method for building link.
utils.buildLink = (bucket, key, tag) -> { bucket : bucket, key : key, tag : tag }
utils.buildLink = (bucket, key, tag) -> {bucket: bucket, key: key, tag: tag}

# Utility method for merging two arrays into one.
utils.mergeArrays = (first, second) -> Array::push.apply first, second

1 change: 0 additions & 1 deletion lib/validators/input.validators.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class ValidationResult

isValid: => !@errorMessage?


# Validate user's data. `username` and `email` are both mandatory.
exports.validateUser = (username, email) ->
# sanitize input params before further validation
Expand Down

0 comments on commit 04af3d3

Please sign in to comment.