Comparing version 0.2.2 to 0.2.3
@@ -0,1 +1,7 @@ | ||
v0.2.3 (2016-06-09) | ||
=================== | ||
- Further fix bugs when working with older Git. | ||
- Fix a bug of asynchronous tasks in `push`. | ||
v0.2.2 (2016-06-09) | ||
@@ -2,0 +8,0 @@ =================== |
@@ -0,1 +1,9 @@ | ||
/* | ||
Please mind the Git versions. We must make it compatible with Git 1.9. So | ||
`tag -l --format` can't be used. Use `for-each-ref --format` instead. | ||
`tag -l --sort` can't be used. Use `sort` in code instead. | ||
`for-each-ref --points-at` can't be used. Use `tag -l --points-at` instead. | ||
`%(taggerdate:iso-strict)` can't be used. Luckily, both Git and JavaScript support RFC2822. | ||
*/ | ||
"use strict"; | ||
@@ -2,0 +10,0 @@ |
@@ -9,6 +9,2 @@ /* | ||
it will also be cached. | ||
Please mind the Git versions. We must make it compatible with Git 1.9+. So | ||
`git tag -l --format` and `%(taggerdate:iso-strict)` can't be used. Luckily, both | ||
Git and JavaScript support RFC2822. | ||
*/ | ||
@@ -353,4 +349,4 @@ | ||
return $git.lines([ | ||
"tag", "-l", "--points-at", $v.id(commitId), "--sort=refname", "gitlock-*" | ||
]); | ||
"tag", "-l", "--points-at", $v.id(commitId), "gitlock-*" | ||
]).sort(); | ||
}; | ||
@@ -357,0 +353,0 @@ |
@@ -256,4 +256,4 @@ "use strict"; | ||
let lockNames = $git.lines([ | ||
"tag", "-l", "--points-at", $v.id(lastCommitId), "--sort=refname", "gitlock-*" | ||
]); | ||
"tag", "-l", "--points-at", $v.id(lastCommitId), "gitlock-*" | ||
]).sort(); | ||
let lockName = $util.last(lockNames); | ||
@@ -276,28 +276,31 @@ let baseTaggerTime = $lock.getTime(lockNames[0]); | ||
console.log(`Sending timestamp request to "${url.hostname}"...`); | ||
let clientRequest = $http.request({ | ||
method: "POST", | ||
hostname: url.hostname, | ||
port: url.port, | ||
path: url.path, | ||
headers: {"Content-Type": "application/timestamp-query"} | ||
}, serverResponse => { | ||
let data = new Buffer([]); | ||
serverResponse.on("data", chunk => { | ||
data = Buffer.concat([data, chunk]); | ||
return new Promise((resolve, reject) => { | ||
let clientRequest = $http.request({ | ||
method: "POST", | ||
hostname: url.hostname, | ||
port: url.port, | ||
path: url.path, | ||
headers: {"Content-Type": "application/timestamp-query"} | ||
}, serverResponse => { | ||
let data = new Buffer([]); | ||
serverResponse.on("data", chunk => { | ||
data = Buffer.concat([data, chunk]); | ||
}); | ||
serverResponse.on("end", () => { | ||
let newLock = new $lock.TimestampLock({parentHash: $lock.getHash(lockName), data: [data]}); | ||
let newLockName = | ||
"gitlock-" + $lock.generateLabel(lockName) + "-" + newLock.hash; | ||
$lock.add( | ||
newLockName, | ||
newLock.storedContent, | ||
lastCommitId, | ||
$util.addTime(baseTaggerTime, 1) | ||
); | ||
console.log(`Timestamp added. Content length: ${data.length}`); | ||
resolve(); | ||
}); | ||
}); | ||
serverResponse.on("end", () => { | ||
let newLock = new $lock.TimestampLock({parentHash: $lock.getHash(lockName), data: [data]}); | ||
let newLockName = | ||
"gitlock-" + $lock.generateLabel(lockName) + "-" + newLock.hash; | ||
$lock.add( | ||
newLockName, | ||
newLock.storedContent, | ||
lastCommitId, | ||
$util.addTime(baseTaggerTime, 1) | ||
); | ||
console.log(`Timestamp added. Content length: ${data.length}`); | ||
}); | ||
clientRequest.write(request); | ||
clientRequest.end(); | ||
}); | ||
clientRequest.write(request); | ||
clientRequest.end(); | ||
}; | ||
@@ -340,12 +343,17 @@ | ||
if (pushDefault === "lock,timestamp") { | ||
addTimestamp(); | ||
addTimestamp().then(() => { | ||
console.log("Applying secure delay. Will continue after 5 seconds..."); | ||
return $util.delay(5000); | ||
}).then(() => { | ||
$git.runWithoutCapture(["push", "--follow-tags"]); | ||
}); | ||
} | ||
else { | ||
$git.runWithoutCapture(["push", "--follow-tags"]); | ||
} | ||
} | ||
else { | ||
console.log("Locks are already up-to-date with no new lock added."); | ||
console.log("Locks are already up-to-date. No new lock added."); | ||
$git.runWithoutCapture(["push", "--follow-tags"]); | ||
} | ||
console.log("Applying secure delay. Please wait 5 seconds..."); | ||
$util.delay(5000).then(() => { | ||
$git.runWithoutCapture(["push", "--follow-tags"]); | ||
}); | ||
} | ||
@@ -414,4 +422,4 @@ else if (args[0] === "verify") { | ||
let lockNames = $git.lines([ | ||
"tag", "-l", "--points-at", $v.idOrHashOrLockName(args[1]), "--sort=refname", "gitlock-*" | ||
]); | ||
"tag", "-l", "--points-at", $v.idOrHashOrLockName(args[1]), "gitlock-*" | ||
]).sort(); | ||
lockNames.forEach(name => { | ||
@@ -446,3 +454,5 @@ console.log(name); | ||
else if (args[0] === "list") { | ||
let lockNames = $git.lines(["tag", "-l", "--sort=taggerdate", "gitlock-*"]); | ||
let lockNames = $git.lines([ | ||
"for-each-ref", "--format=%(refname:short)", "--sort=taggerdate", "refs/tags/gitlock-*" | ||
]); | ||
lockNames.forEach(name => { | ||
@@ -473,4 +483,4 @@ console.log(name); | ||
let lockNames = $git.lines([ | ||
"tag", "-l", "--points-at", $v.id($git.getLastCommitId()), "--sort=refname", "gitlock-*" | ||
]); | ||
"tag", "-l", "--points-at", $v.id($git.getLastCommitId()), "gitlock-*" | ||
]).sort(); | ||
removeLocks(lockNames); | ||
@@ -480,4 +490,4 @@ } | ||
let lockNames = $git.lines([ | ||
"tag", "-l", "--points-at", $v.id($git.getLastCommitId()), "--sort=refname", "gitlock-*" | ||
]); | ||
"tag", "-l", "--points-at", $v.id($git.getLastCommitId()), "gitlock-*" | ||
]).sort(); | ||
let last = $util.last(lockNames); | ||
@@ -484,0 +494,0 @@ if ($lock.getLabel(last) !== "000") { |
{ | ||
"name": "gitlock", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "Add a SHA-256 wrapper to increase the security of Git. It can also protect your copyright by adding timestamps from trusted Time Stamping Authority.", | ||
@@ -5,0 +5,0 @@ "keywords": ["git", "lock"], |
@@ -73,3 +73,3 @@ "use strict"; | ||
let getLocks = commitId => { | ||
let lockNames = execToLines(`git tag -l --points-at ${commitId} --sort=refname gitlock-*`); | ||
let lockNames = execToLines(`git tag -l --points-at ${commitId} gitlock-*`).sort(); | ||
return lockNames.map((lockName, index) => { | ||
@@ -76,0 +76,0 @@ let r = {name: lockName, content: execGitlock("show-content " + lockName)}; |
125380
2171