mirror of
https://github.com/danog/gift.git
synced 2024-11-30 04:19:37 +01:00
Merge pull request #20 from Lance0312/pr
Support gpgsig parsing and some extra fixes
This commit is contained in:
commit
5fcea7fbbd
@ -3,7 +3,7 @@ Actor = require './actor'
|
||||
Tree = require './tree'
|
||||
|
||||
module.exports = class Commit
|
||||
constructor: (@repo, @id, parents, tree, @author, @authored_date, @committer, @committed_date, @message) ->
|
||||
constructor: (@repo, @id, parents, tree, @author, @authored_date, @committer, @committed_date, @gpgsig, @message) ->
|
||||
# Public: Get the commit's Tree.
|
||||
#
|
||||
# Returns Tree.
|
||||
@ -71,17 +71,20 @@ module.exports = class Commit
|
||||
parents.push _.last lines.shift().split(" ")
|
||||
|
||||
author_line = lines.shift()
|
||||
if !/^committer /.test(lines[0])
|
||||
author_line.push lines.shift()
|
||||
[author, authored_date] = @actor author_line
|
||||
|
||||
committer_line = lines.shift()
|
||||
if lines[0] && !/^encoding/.test(lines[0])
|
||||
committer_line.push lines.shift()
|
||||
[committer, committed_date] = @actor committer_line
|
||||
|
||||
gpgsig = []
|
||||
if /^gpgsig/.test lines[0]
|
||||
gpgsig.push lines.shift().replace /^gpgsig /, ''
|
||||
while !/^ -----END PGP SIGNATURE-----$/.test lines[0]
|
||||
gpgsig.push lines.shift()
|
||||
gpgsig.push lines.shift()
|
||||
|
||||
# not doing anything with this yet, but it's sometimes there
|
||||
if /^encoding/.test lines.first
|
||||
if /^encoding/.test lines[0]
|
||||
encoding = _.last lines.shift().split(" ")
|
||||
|
||||
lines.shift()
|
||||
@ -93,7 +96,7 @@ module.exports = class Commit
|
||||
while lines[0]? && !lines[0].length
|
||||
lines.shift()
|
||||
|
||||
commits.push new Commit(repo, id, parents, tree, author, authored_date, committer, committed_date, message_lines.join("\n"))
|
||||
commits.push new Commit(repo, id, parents, tree, author, authored_date, committer, committed_date, gpgsig.join("\n"), message_lines.join("\n"))
|
||||
return commits
|
||||
|
||||
|
||||
|
@ -5,6 +5,7 @@ dir = "#{__dirname}/fixtures"
|
||||
module.exports =
|
||||
branched: git("#{dir}/branched", true)
|
||||
checkout: git("#{dir}/checkout", true)
|
||||
gpgsigned: git("#{dir}/gpgsigned", true)
|
||||
remotes: git("#{dir}/remotes", true)
|
||||
simple: git("#{dir}/simple", true)
|
||||
status: git("#{dir}/status", true)
|
||||
|
1
test/fixtures/gpgsigned/HEAD
vendored
Normal file
1
test/fixtures/gpgsigned/HEAD
vendored
Normal file
@ -0,0 +1 @@
|
||||
ref: refs/heads/master
|
4
test/fixtures/gpgsigned/config
vendored
Normal file
4
test/fixtures/gpgsigned/config
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = true
|
||||
bare = true
|
1
test/fixtures/gpgsigned/description
vendored
Normal file
1
test/fixtures/gpgsigned/description
vendored
Normal file
@ -0,0 +1 @@
|
||||
Fixture for testing gift with gpg signed commits
|
BIN
test/fixtures/gpgsigned/objects/50/702b21b3b51da55bf4006185133a4173efde62
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/50/702b21b3b51da55bf4006185133a4173efde62
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/gpgsigned/objects/a5/e51a8a6b1fe4d0339c170a04c332bf0497e5bb
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/a5/e51a8a6b1fe4d0339c170a04c332bf0497e5bb
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/gpgsigned/objects/a7/9e4f2537e8228361a0961f9b66108723a7679b
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/a7/9e4f2537e8228361a0961f9b66108723a7679b
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/gpgsigned/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/gpgsigned/objects/ec/2c2e08e7dd8ce60d863c5bbd9563db03487d35
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/ec/2c2e08e7dd8ce60d863c5bbd9563db03487d35
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/gpgsigned/objects/f4/4d5893d23b79141d8b525edc1375821937b3e6
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/f4/4d5893d23b79141d8b525edc1375821937b3e6
vendored
Normal file
Binary file not shown.
BIN
test/fixtures/gpgsigned/objects/f6/7b3352d57e26a71ccf0b35d87f6c68161f9c0a
vendored
Normal file
BIN
test/fixtures/gpgsigned/objects/f6/7b3352d57e26a71ccf0b35d87f6c68161f9c0a
vendored
Normal file
Binary file not shown.
1
test/fixtures/gpgsigned/refs/heads/master
vendored
Normal file
1
test/fixtures/gpgsigned/refs/heads/master
vendored
Normal file
@ -0,0 +1 @@
|
||||
ec2c2e08e7dd8ce60d863c5bbd9563db03487d35
|
@ -248,6 +248,35 @@ describe "Repo", ->
|
||||
it "returns 2 commits", ->
|
||||
commits[0].message.should.include "commit 4"
|
||||
|
||||
describe "with or without gpg signature", ->
|
||||
repo = fixtures.gpgsigned
|
||||
commits = null
|
||||
before (done) ->
|
||||
repo.commits "master", (err, _commits) ->
|
||||
commits = _commits
|
||||
done err
|
||||
|
||||
it "has no gpgsig", ->
|
||||
commits[0].gpgsig.should.not.be.ok
|
||||
|
||||
it "has gpgsig", ->
|
||||
commits[1].gpgsig.should.be.ok
|
||||
|
||||
it "contains the correct signature", ->
|
||||
commits[1].gpgsig.should.equal """
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v2.0.22 (GNU/Linux)
|
||||
|
||||
iQEcBAABAgAGBQJTQw8qAAoJEL0/h9tqDFPiP3UH/RwxUS90+6DEkThcKMmV9H4K
|
||||
dr+D0H0z2ViMq3AHSmCydv5dWr3bupl2XyaLWWuRCxAJ78xuf98qVRIBfT/FKGeP
|
||||
fz+GtXkv3naCD12Ay6YiwfxSQhxFiJtRwP5rla2i7hlV3BLFPYCWTtL8OLF4CoRm
|
||||
7aF5EuDr1x7emEDyu1rf5E59ttSIySuIw0J1mTjrPCkC6lsowzTJS/vaCxZ3e7fN
|
||||
iZE6VEWWY/iOxd8foJH/VZ3cfNKjfi8+Fh8t7o9ztjYTQAOZUJTn2CHB7Wkyr0Ar
|
||||
HNM3v26gPFpb7UkHw0Cq2HWNV/Z7cbQc/BQ4HmrmuBPB6SWNOaBN751BbQKnPcA=
|
||||
=IusH
|
||||
-----END PGP SIGNATURE-----
|
||||
"""
|
||||
|
||||
describe "#tree", ->
|
||||
repo = fixtures.branched
|
||||
describe "master", ->
|
||||
|
Loading…
Reference in New Issue
Block a user