Skip to content

Commit 21d7c26

Browse files
committed
fix bug with car loader. update web styles for macos.
1 parent efde275 commit 21d7c26

File tree

10 files changed

+64
-14
lines changed

10 files changed

+64
-14
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/alecthomas/chroma v0.8.2
77
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
88
github.com/ipfs/go-bitswap v0.3.2
9+
github.com/ipfs/go-block-format v0.0.2
910
github.com/ipfs/go-blockservice v0.1.4
1011
github.com/ipfs/go-cid v0.0.7
1112
github.com/ipfs/go-datastore v0.4.5

pkg/command/context.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
)
2323

2424
// IgnoreRules contains default ignore rules.
25-
var IgnoreRules = []string{".git", "node_modules", DotDir}
25+
var IgnoreRules = []string{".git", DotDir}
2626

2727
// Context contains command context.
2828
type Context struct {

pkg/command/push.go

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ func NewPushCommand() *cli.Command {
5151
return err
5252
}
5353

54+
// TODO use merge base to check if branch is valid
55+
5456
refs := repo.Heads()
5557
walk := func(node ipld.Node) ([]*ipld.Link, error) {
5658
if refs.Has(node.Cid()) {

pkg/http/push.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package http
22

33
import (
44
"errors"
5+
"io"
56
"net/http"
67

8+
blocks "github.com/ipfs/go-block-format"
79
car "github.com/ipld/go-car"
810
"github.com/julienschmidt/httprouter"
911
"github.com/libp2p/go-libp2p-core/peer"
@@ -45,18 +47,28 @@ func (s *Service) Push(w http.ResponseWriter, req *http.Request) error {
4547
return err
4648
}
4749

48-
header, err := car.LoadCar(s.Peer.Blocks, req.Body)
50+
r, err := car.NewCarReader(req.Body)
4951
if err != nil {
5052
return err
5153
}
5254

53-
if len(header.Roots) != 1 {
55+
if len(r.Header.Roots) != 1 {
5456
return errors.New("unexpected header roots")
5557
}
5658

59+
for block := blocks.Block(nil); err != io.EOF; block, err = r.Next() {
60+
if err != nil {
61+
return err
62+
}
63+
64+
if err := s.Peer.Blocks.Put(block); err != nil {
65+
return err
66+
}
67+
}
68+
5769
// TODO use merge base to check if new root is valid
5870

59-
repo.Branches[bname] = header.Roots[0]
71+
repo.Branches[bname] = r.Header.Roots[0]
6072
if repo.DefaultBranch == "" {
6173
repo.DefaultBranch = bname
6274
}

web/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@snowpack/plugin-postcss": "^1.1.0",
2323
"@snowpack/plugin-svelte": "^3.5.2",
2424
"@tailwindcss/forms": "^0.2.1",
25+
"@tailwindcss/typography": "^0.4.0",
2526
"autoprefixer": "^10.2.4",
2627
"concurrently": "^6.0.0",
2728
"electron": "^11.3.0",

web/src/components/NavBar.svelte

+9-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
}
2222
2323
function clickBreadcrumb(index) {
24-
path.set(`/${breadcrumbs.slice(0, index+1).join('/')}`)
24+
const offset = breadcrumbs.length > 3 ? breadcrumbs.length - 2 : 1
25+
const subpath = breadcrumbs.slice(0, offset+index).join('/')
26+
path.set(`/${subpath}`)
2527
}
2628
</script>
2729

@@ -32,7 +34,11 @@
3234
<a href="#" on:click={() => $path = ''} class="text-lg font-semibold">
3335
{$remote.split('/').pop()}
3436
</a>
35-
{#each breadcrumbs as c, i}
37+
{#if breadcrumbs.length > 3}
38+
<span class="text-gray-400 text-lg">/</span>
39+
<span class="text-gray-400 text-lg">..</span>
40+
{/if}
41+
{#each breadcrumbs.slice(-3) as c, i}
3642
<span class="text-gray-400 text-lg">/</span>
3743
<a href="#" on:click={() => clickBreadcrumb(i) } class="text-lg font-semibold">
3844
{c}
@@ -55,7 +61,7 @@
5561
</div>
5662
{#if branchMenu}
5763
<div class="absolute origin-top-right right-0 mt-2 rounded-md shadow-lg bg-white divide-y divide-gray-100" role="menu" aria-orientation="vertical">
58-
<div class="py-1">
64+
<div class="py-2">
5965
{#each branches as b}
6066
<a href="#" class="px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 hover:text-gray-900" role="menuitem">{b}</a>
6167
{/each}

web/src/components/SideBar.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<div class="h-6 w-full" style="-webkit-app-region: drag">
1515
<!-- draggable area -->
1616
</div>
17-
<div class="pl-4 pr-6" >
17+
<div class="pl-4 pr-6 mt-6" >
1818
<div class="flex items-center justify-between">
1919
<div class="flex-1 space-y-8">
2020
<div class="space-y-8 block space-y-8">

web/src/pages/Repo.svelte

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
{#if Array.isArray($file)}
99
<Tree entries={$file} />
1010
{:else if typeof $file === 'string'}
11-
{@html $file}
11+
<article class="text-sm">
12+
{@html $file}
13+
</article>
1214
{/if}
1315
</div>

web/tailwind.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ module.exports = {
99
},
1010
plugins: [
1111
require('@tailwindcss/forms'),
12+
require('@tailwindcss/typography'),
1213
],
1314
}

web/yarn.lock

+30-5
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,16 @@
369369
dependencies:
370370
mini-svg-data-uri "^1.2.3"
371371

372+
"@tailwindcss/typography@^0.4.0":
373+
version "0.4.0"
374+
resolved "https://registry.yarnpkg.com/@tailwindcss/typography/-/typography-0.4.0.tgz#b80974ad6af93df7b06e1981cb4d79698b6ad5c7"
375+
integrity sha512-3BfOYT5MYNEq81Ism3L2qu/HRP2Q5vWqZtZRQqQrthHuaTK9qpuPfbMT5WATjAM5J1OePKBaI5pLoX4S1JGNMQ==
376+
dependencies:
377+
lodash.castarray "^4.4.0"
378+
lodash.isplainobject "^4.0.6"
379+
lodash.merge "^4.6.2"
380+
lodash.uniq "^4.5.0"
381+
372382
"@types/cacheable-request@^6.0.1":
373383
version "6.0.1"
374384
resolved "https://registry.yarnpkg.com/@types/cacheable-request/-/cacheable-request-6.0.1.tgz#5d22f3dded1fd3a84c0bbeb5039a7419c2c91976"
@@ -2382,6 +2392,11 @@ lodash._reinterpolate@^3.0.0:
23822392
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
23832393
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
23842394

2395+
lodash.castarray@^4.4.0:
2396+
version "4.4.0"
2397+
resolved "https://registry.yarnpkg.com/lodash.castarray/-/lodash.castarray-4.4.0.tgz#c02513515e309daddd4c24c60cfddcf5976d9115"
2398+
integrity sha1-wCUTUV4wna3dTCTGDP3c9ZdtkRU=
2399+
23852400
lodash.difference@^4.5.0:
23862401
version "4.5.0"
23872402
resolved "https://registry.yarnpkg.com/lodash.difference/-/lodash.difference-4.5.0.tgz#9ccb4e505d486b91651345772885a2df27fd017c"
@@ -2402,6 +2417,16 @@ lodash.groupby@^4.6.0:
24022417
resolved "https://registry.yarnpkg.com/lodash.groupby/-/lodash.groupby-4.6.0.tgz#0b08a1dcf68397c397855c3239783832df7403d1"
24032418
integrity sha1-Cwih3PaDl8OXhVwyOXg4Mt90A9E=
24042419

2420+
lodash.isplainobject@^4.0.6:
2421+
version "4.0.6"
2422+
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
2423+
integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=
2424+
2425+
lodash.merge@^4.6.2:
2426+
version "4.6.2"
2427+
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
2428+
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
2429+
24052430
lodash.sortby@^4.7.0:
24062431
version "4.7.0"
24072432
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@@ -2427,6 +2452,11 @@ lodash.toarray@^4.4.0:
24272452
resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561"
24282453
integrity sha1-JMS/zWsvuji/0FlNsRedjptlZWE=
24292454

2455+
lodash.uniq@^4.5.0:
2456+
version "4.5.0"
2457+
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
2458+
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
2459+
24302460
lodash@^4.17.10, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@^4.17.4:
24312461
version "4.17.21"
24322462
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
@@ -3257,11 +3287,6 @@ prepend-http@^2.0.0:
32573287
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
32583288
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
32593289

3260-
3261-
version "2.2.1"
3262-
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
3263-
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==
3264-
32653290
pretty-bytes@^1.0.2:
32663291
version "1.0.4"
32673292
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84"

0 commit comments

Comments
 (0)