Safenetwork Git Portal Discussion

I’m trying to get portal running locally, so I could help with the UX stuff, but have some problems get it running.

OS: macOS Big Sur 11.0.1
GO: 1.15.5
node: 14.14

First I got this error when building the project:

Error: Command failed: /usr/local/Cellar/go/1.15.5/libexec/bin/go build -o /Users/miikat/src/go/p2p-git-portal-poc/src/main.go.wasm /Users/miikat/src/go/p2p-git-portal-poc/src/main.go
go: github.com/MichaelMure/git-bug@v0.0.0-20201205005248-54d123c6753d: parsing /home/mrh/src/go/src/github.com/happybeing/git-bug/go.mod: open /home/mrh/src/go/src/github.com/happybeing/git-bug/go.mod: no such file or directory

I then cloned the repos what I found in go.mod -file(git-bug, keyring, webpack-golang-wasm-async-loader) and modified the replace locations to match my local machine. After that I got this error:

    Error: Command failed: /usr/local/Cellar/go/1.15.5/libexec/bin/go build -o /Users/miikat/src/go/p2p-git-portal-poc/src/main.go.wasm /Users/miikat/src/go/p2p-git-portal-poc/src/main.go
    # github.com/happybeing/p2p-git-portal-poc/src/repo
    ../../../go_wasm/p2p-git-portal-poc/src/repo/repo_gitbug.go:117:15: undefined: repository.InitFsGoGitRepo
    ../../../go_wasm/p2p-git-portal-poc/src/repo/repo_gitbug.go:155:15: undefined: repository.OpenFsGoGitRepo

Any ideas what could be wrong?

1 Like

Hey, Miika thanks for posting and offering to help.

Looks to me like you are nearly there, and I may need to improve the instructions in the README. The things which are undefined are in my fork of git-bug https://github.com/happybeing/git-bug

These should already be picked up for you by the replace statements here: https://github.com/happybeing/p2p-git-portal-poc/blob/main/src/go.mod#L14

Are you using branch main?

That ensures you are using my forks of git-bug, go-git and go-billy: https://github.com/happybeing/git-bug https://github.com/happybeing/go-git/go-git and https://github.com/happybeing/go-git/go-billy

So you should not need to clone these and have local copies unless you plan to work on them. For that case you would change the redirect statements to point to the local paths on your Mac as explained in the README here. But as noted, you probably don’t need that.

So first check what’s in your go.mod to make sure there’s a suitable replace for all three.

Note that Golang can be a bit tricky sometimes. It auto edits the import and require sections for you if you don’t get it right, but often messes them up as a result.

EDIT: as you may have noticed, here’s the source of the problem in go.mod, I’ve accidentally checked in to version I’m using for development. The following local paths need to have the /home/mrh/src/go/src/ removed. Please try that and let me know how you get on:

replace github.com/MichaelMure/git-bug => /home/mrh/src/go/src/github.com/happybeing/git-bug

replace github.com/99designs/keyring => /home/mrh/src/go/src/github.com/happybeing/keyring

replace github.com/happybeing/p2p-git-portal-poc/src/repo => /home/mrh/src/wasm/p2p-git-portal-poc/src/repo

1 Like

Thanks happybeing. Using the main branch. Commented out the replace statements that points to local paths. This is how go.mod looks now:

module github.com/happybeing/p2p-git-portal-poc

go 1.13

require (
	github.com/MichaelMure/git-bug v0.0.0-20201205005248-54d123c6753d
	github.com/go-git/go-billy/v5 v5.0.0
	github.com/go-git/go-git/v5 v5.2.0
	github.com/happybeing/p2p-git-portal-poc/src/repo v0.0.0

	github.com/happybeing/webpack-golang-wasm-async-loader/gobridge v0.0.0-20201125123737-917b0db1c9a8
)

// Use forks with Go/wasm support
replace github.com/go-git/go-git/v5 => github.com/happybeing/go-git/v5 v5.2.1

replace github.com/go-git/go-billy/v5 => github.com/happybeing/go-billy/v5 v5.0.1

// For development with local go-git/go-billy and wasm plugin:
//replace github.com/MichaelMure/git-bug => /home/mrh/src/go/src/github.com/happybeing/git-bug

//replace github.com/99designs/keyring => /home/mrh/src/go/src/github.com/happybeing/keyring

//replace github.com/happybeing/p2p-git-portal-poc/src/repo => /home/mrh/src/wasm/p2p-git-portal-poc/src/repo

// Dependencies of git-bug which require tweaks for wasm
// replace github.com/99designs/keyring => /home/mrh/src/go/src/github.com/happybeing/keyring

// replace github.com/go-git/go-git/v5 => /home/mrh/src/go/src/github.com/happybeing/go-git
// replace github.com/go-git/go-billy/v5 => /home/mrh/src/go/src/github.com/happybeing/go-billy

// To develop with a local version of the plugin you need to:
// - uncomment the following 'replace'
// - `yarn link` in your local development copy of the plugin
// - `yarn link golang-wasm-async-loader2` in ./p2p-git-portal-poc
// replace github.com/happybeing/webpack-golang-wasm-async-loader/gobridge => /home/mrh/src/go/src/github.com/happybeing/webpack-golang-wasm-async-loader/gobridge

This is the error I get now. This might be some mac git thing…

go: github.com/happybeing/p2p-git-portal-poc/src/repo@v0.0.0: reading github.com/happybeing/p2p-git-portal-poc/src/repo/src/repo/go.mod at revision src/repo/v0.0.0: unknown revision src/repo/v0.0.0

2 Likes

No it’s not a Mac thing. You’re on the right track but I’ll have to leave this until tomorrow. Feel free to wait, or see if you can fix it by redirecting the to the github.com/happybeing forks. See my not quite correct EDIT to my first reply above, or wait for me to fix it tomorrow, up to you!

Tried main/master and p2p-git-portal-poc branches on those forks. Always same error in the end:

repo/repo_gitbug.go:117:15: undefined: repository.InitFsGoGitRepo repo/repo_gitbug.go:155:15: undefined: repository.OpenFsGoGitRepo

This is how my replacements look:

replace github.com/go-git/go-git/v5 => github.com/happybeing/go-git/v5 v5.2.1

replace github.com/go-git/go-billy/v5 => github.com/happybeing/go-billy/v5 v5.0.1

// For development with local go-git/go-billy and wasm plugin:

replace github.com/MichaelMure/git-bug => github.com/happybeing/git-bug v0.0.0-20201130154430-c1cc81ddffc6

replace github.com/99designs/keyring => github.com/happybeing/keyring v1.1.7-0.20201125173032-516124edd048

replace github.com/happybeing/p2p-git-portal-poc/src/repo => /Users/miikat/src/go_wasm/p2p-git-portal-poc/src/repo

Sorry to leave you with this. I’m pretty sure I messed up by checking in my development go.mod (when I merged my development branch) so what you need is an older one from main branch than one from a different branch.

If you like, you could try this one, or as I say wait for me to sort it out tomorrow. I’m on my tablet now, so I can’t test it out yet:

Well done for getting this far. Golang is quite tricky in this area and it easily throws you off and doesn’t give much help with this.

No worries, thanks for your help. I’ll continue with this tonight.

I’m struggling to get this working with replacements pointing to github.com/happybeing at the moment so I suggest using local forks as we should find that easier to get working. Once you have the forks, and they are located in the correct place, you would need to modify p2p-git-portal-poc/src/go.mod to point to those rather than the paths on my system.

I’m not sure where the forks will need to be on your system. This needs to be in a particular place, in my case I used /home/mrh/src/go/src/ which is non-standard because I like all my code under ~/src but I can’t remember how this is set.

The only thing in my environment is that my $PATH contains /home/mrh/src/go/bin, where the bin directory is next to the src/ that you need to locate. If I do ls /mrh/src/go it contains only the following: bin/ pkg/ src/

When you locate that src/, you would create a path corresponding to your github.com/<your-account> with mkdir -p github.com/<your-account> then cd github.com/<your-account> and git clone your forks of my git-bug, go-git and go-billy so you have paths for each beginning .../src/github.com/<your-account>/git-bug etc.

You may also need forks of github.com/happybeing/keyring and github.com/happybeing/webpack-golang-wasm-async-loader so start with those too for now.

Once you have that set up, check out the main branch p2p-git-portal-poc/src/go.mod and modify it the replacements pointing to paths beginning with /home/mrh/src/go/src/github.com/happybeing begin with your <path-to-src>/github.com/<your-account> path. Then yarn build and hope for the best!

I think I had this working as in the README instructions using the references to repos on github, but have obviously broken that at some point so it is inconvenient to anyone to use my forks for now. If you can get things working as I’ve described we can leave this until the forks settle down a bit and I’ll just have to let you know when you need to pull changes.

Sorry this is so complicated!

1 Like

Got it working now! I guess I had wrong fork branches yesterday. I didn’t have to fork myself anything, just added master branches to go.mod replaces. This is how my go.mod looks now:

module github.com/happybeing/p2p-git-portal-poc

go 1.13

require (
	github.com/MichaelMure/git-bug v0.0.0-20201205005248-54d123c6753d
	github.com/go-git/go-billy/v5 v5.0.0
	github.com/go-git/go-git/v5 v5.2.0
	github.com/happybeing/p2p-git-portal-poc/src/repo v0.0.0

	github.com/happybeing/webpack-golang-wasm-async-loader/gobridge v0.0.0-20201125123737-917b0db1c9a8
)

// Use forks with Go/wasm support
replace github.com/go-git/go-git/v5 => github.com/happybeing/go-git/v5 v5.2.1

replace github.com/go-git/go-billy/v5 => github.com/happybeing/go-billy/v5 v5.0.1

// For development with local go-git/go-billy and wasm plugin:
replace github.com/MichaelMure/git-bug => github.com/happybeing/git-bug master

replace github.com/99designs/keyring => github.com/happybeing/keyring master

replace github.com/happybeing/p2p-git-portal-poc/src/repo => /Users/miikat/src/go_wasm/p2p-git-portal-poc/src/repo

// Dependencies of git-bug which require tweaks for wasm
// replace github.com/99designs/keyring => /home/mrh/src/go/src/github.com/happybeing/keyring

// replace github.com/go-git/go-git/v5 => /home/mrh/src/go/src/github.com/happybeing/go-git
// replace github.com/go-git/go-billy/v5 => /home/mrh/src/go/src/github.com/happybeing/go-billy

// To develop with a local version of the plugin you need to:
// - uncomment the following 'replace'
// - `yarn link` in your local development copy of the plugin
// - `yarn link golang-wasm-async-loader2` in ./p2p-git-portal-poc
//replace github.com/happybeing/webpack-golang-wasm-async-loader/gobridge => /Users/miikat/src/go/webpack-golang-wasm-async-loader/gobridge
9 Likes

Well done! Looks like a good first PR.

Do you have a link to info about using ‘master’ in the replace statement, I haven’t seen that.

1 Like

Made a PR. I don’t have a link for you about using master. I just tried it and it worked: ) Go will replace that with correct version number on build.

6 Likes

Thanks for solving this, for the PR and this important learning. A great start!

Edit: @Miguelo, apparently you can specify a few things instead of a version. I wish the error messages didn’t lead you to a dead end, see: https://matrix.to/#/!nFnLAdlvBgcHWsPUmS:gitter.im/$iNXPWHCDu35Uf_Ofsfna1JcOGJEhFMNp-nAWolX0H4E?via=matrix.org&via=gitter.im&via=ajay.app

8 Likes

Progress Update

I’ve added a simple file browser so you can view the contents of repository storage.

Live: https://gitch.happybeing.com
Code: https://github.com/happyborg/p2p-git-portal-poc

@Miguelo I’ve pushed the changes to main.

5 Likes

Nice work. Is it still Linux-only because of the CORS issue? I get a network error on Windows trying to clone a repo.

Edit - using the Firefox extension CorsE (Windows) gives a different error on cloning a repo:
clone failed: invalid pkt-len found

1 Like

When the Safenetwork holds the main code repo for the Safenetwork will be amazing.

7 Likes

I’m not aware of any Windows specific issues. If you use a proxy it should be fine regardless of operating system. If you can’t do that yourself, try entering https://cors.isomorphic-git.org/ in the CORS proxy box before cloning. I just tried it with the live version at http://gitch.happybeing.com/ (in Firefox) and it worked fine.

I suggest creating a new repo first, and wait until this appears as it takes a little while to load the bundle the first time. Then try cloning. You can open the browser console to see more about what’s going on (as I don’t have any progress indication yet).

Thanks for trying it out.

1 Like

Yes that works. Nice!

2 Likes

Git Portal Update

I’ve added the ability to upload a repository and @Miguelo has been learning Svelte, Golang and beginning to work on a more github like UI so you may not have to look at my ugly thing much longer.

Note: upload repository is only viable for fairly small repositories as there seems to be a limit of a few thousand files in one go. #issue

I’ve also updated the README so any proof reading and suggestions to improve that are welcome.

Live demo: http://gitch.happybeing.com/
Code and help: https://github.com/happyborg/p2p-git-portal-poc#p2p-git-portal---proof-of-concept

Screenshot:

14 Likes

Here’s a preview what I’ve been tinkering with.

26 Likes

Looks awesome!! :grinning_face_with_smiling_eyes:

9 Likes