Skip to content

Commit

Permalink
Use sha1-regex to improve commit id/hash test, cc #96
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterDaveHello committed Nov 6, 2017
1 parent b609d3d commit 7d126eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"url": "https://github.com/notatestuser/gift.git"
},
"dependencies": {
"sha1-regex": "^1.0.0",
"underscore": "1.x.x"
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion src/commit.coffee
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
_ = require 'underscore'
Actor = require './actor'
Tree = require './tree'
sha1 = require 'sha1-regex'

module.exports = class Commit
constructor: (@repo, @id, parents, tree, @author, @authored_date, @committer, @committed_date, @gpgsig, @message) ->
Expand Down Expand Up @@ -83,7 +84,7 @@ module.exports = class Commit
lines = text.split "\n"
while lines.length
id = _.last lines.shift().split(" ")
break if !id
break if !sha1.test(id)
tree = _.last lines.shift().split(" ")

parents = []
Expand Down

0 comments on commit 7d126eb

Please sign in to comment.