From e78082c5e3b4adc56a54d6b012c079302dfcb534 Mon Sep 17 00:00:00 2001 From: Chris Ball Date: Wed, 13 May 2015 18:11:57 -0400 Subject: Fix up standard linter warnings --- git-remote-gitswarm | 27 ++++++++++++++------------- gitswarmd | 13 ++++++------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/git-remote-gitswarm b/git-remote-gitswarm index 517de84..5524518 100755 --- a/git-remote-gitswarm +++ b/git-remote-gitswarm @@ -7,7 +7,7 @@ var Swarm = require('bittorrent-swarm') var ut_gitswarm = require('ut_gitswarm') // We use console.warn (stderr) because git ignores our writes to stdout. -url = process.argv[3].replace(/^gitswarm:/i, 'git:') +var url = process.argv[3].replace(/^gitswarm:/i, 'git:') function die (error) { console.error(error) @@ -15,22 +15,23 @@ function die (error) { } exec('git ls-remote ' + url + ' HEAD', function (err, stdout, stderr) { - if (err !== null) + if (err !== null) { die(err) - - lines = stdout.split('\n') - if (lines.length !== 2) + } + var lines = stdout.split('\n') + if (lines.length !== 2) { die("Didn't get back a single HEAD ref: " + lines) - + } var line = lines[0].split('\t') var ref = line[0] var head = line[1] - if (head !== 'HEAD') + if (head !== 'HEAD') { die("Couldn't parse the ref line: " + ref, head) - if (ref.length != 40) - die("Was expecting a 40-byte sha: " + ref) - - console.warn("Okay, we want to get: " + ref) + } + if (ref.length !== 40) { + die('Was expecting a 40-byte sha: ' + ref) + } + console.warn('Okay, we want to get: ' + ref) var dht = new DHT() var magnetUri = 'magnet:?xt=urn:btih:' + ref @@ -44,9 +45,9 @@ exec('git ls-remote ' + url + ' HEAD', function (err, stdout, stderr) { }) var swarm = new Swarm(parsed.infoHash, 'cafebabecafebabecafecafebabecafebabecafe') - swarm.on('wire', function(wire) { + swarm.on('wire', function (wire) { console.error('we got a wire') wire.use('ut_gitswarm') - //wire.ut_gitswarm.askforsha(parsed.infoHash) + // wire.ut_gitswarm.askforsha(parsed.infoHash) }) }) diff --git a/gitswarmd b/gitswarmd index 4ec7fb5..8060de3 100755 --- a/gitswarmd +++ b/gitswarmd @@ -7,7 +7,6 @@ var net = require('net') var Protocol = require('bittorrent-protocol') var spawn = require('child_process').spawn var Swarm = require('bittorrent-swarm') -var WebTorrent = require('webtorrent') var ut_gitswarm = require('ut_gitswarm') function die (error) { @@ -32,8 +31,8 @@ repos.forEach(function (repo) { upload.stdout.on('data', function (line) { var lines = line.toString().split('\n') lines.forEach(function (line) { - arr = line.toString().split(' ') - if (arr.length == 2) { + var arr = line.toString().split(' ') + if (arr.length === 2) { var sha = arr[0].toString() // First four chars are git-upload-pack's length-of-line metadata. sha = sha.substring(4) @@ -43,8 +42,9 @@ repos.forEach(function (repo) { announcedRefs[sha] = repo console.log(announcedRefs) dht.announce(sha, 30000, function (err) { - if (err !== null) + if (err !== null) { console.log('Announced ' + sha) + } }) } } @@ -54,8 +54,9 @@ repos.forEach(function (repo) { console.log('end') }) upload.on('exit', function (code) { - if (code != 0) + if (code !== 0) { die('Failed: ' + code) + } }) }) @@ -68,5 +69,3 @@ net.createServer(function (socket) { wire.use('ut_gitswarm') }) }).listen(30000) - - -- cgit v1.2.3