rodrigo-brito / gocity

:bar_chart: Code City metaphor for visualizing Go source code in 3D
https://go-city.github.io
MIT License
1.8k stars 139 forks source link

Add support for private git repo #11

Closed lacombar closed 5 years ago

lacombar commented 5 years ago

if anybody is interested, it can be hacked quickly with:

diff --git a/lib/fetch.go b/lib/fetch.go
index 8f875be..ba63b02 100644
--- a/lib/fetch.go
+++ b/lib/fetch.go
@@ -27,7 +27,9 @@ func (fetcher) packageFound(name string) bool {
 }

 func (f *fetcher) Fetch(name string) error {
-       gitAddress := fmt.Sprintf("https://%s", name)
+       gitAddress := "https://"
+       gitAddress += "<your-credentials>"
+       gitAddress += name
        folder := fmt.Sprintf("%s/src/%s", os.Getenv("GOPATH"), name)

        _, err := git.PlainClone(folder, false, &git.CloneOptions{
lacombar commented 5 years ago

it would be great if the backend could directly these credentials from ~/.gitconfig following https://git-scm.com/docs/gitcredentials

rodrigo-brito commented 5 years ago

I don't understand the security issue. It is private and the URL was scaped before used. I think that is not a problem. About the use with private repositories I agree. I will remove the Google Cloud Dependency and release a new version soon.

JackTiger commented 5 years ago

@rodrigo-brito When can the private repositories in using such a library function? If I create a private git repository to manage my projects in private clouds, I want to use this cool function to watch my project, That is very great!

rodrigo-brito commented 5 years ago

Hi @JackTiger, I'm planing to include a binary version to extract data and run the server locally or in an server. Maybe in the next month.

JackTiger commented 5 years ago

@rodrigo-brito How's it going, really looking forward to this feature!

lacombar commented 5 years ago

@JackTiger I hack away a version shortly after opening this issue, available in my fork in the wip branch. Private repo support only require you to edit lib/fetch.go on line 31 to add your api key.

rodrigo-brito commented 5 years ago

Hi @JackTiger, I saw your job with the MemoryStorage, very nice. Feel welcome to contribute with the project. It will be a nice contribution.

About the support to private repositories, I pretend to transform the project in a CLI command. The CLI receive a project URL ou local path and run the GoCity locally, I think it can reduce security issues and solve this problem.

rodrigo-brito commented 5 years ago

Hi @JackTiger and @lacombar Now you can install gocity locally and open private projects in $GOPATH with:

Install gocity with go get:

go get -u github.com/rodrigo-brito/gocity

Open a project

gocity open github.com/your-user/project-name

It will open a server in localhost.

JackTiger commented 5 years ago

Very Nice, I Can't wait to try it. Thank you very much!

JackTiger commented 5 years ago

@rodrigo-brito Hi, When I use this cmd to open a local project, gocity open github.com/your-user/project-name

the path para is a local path or github url or gopath ?

Can I direct analysis local directory using gocity?

When I run this cmd in my local, display the message as below:

D:\progma\Go\bin>gocity.exe open github.com/adohe/etcd-dashboard
time="2019-02-18T14:06:00+08:00" level=info msg="Server started at http://localh
ost:4000"
time="2019-02-18T14:06:01+08:00" level=info msg="opening http://localhost:4000/#
/github.com/adohe/etcd-dashboard"
2019/02/18 14:06:32 http: proxy error: dial tcp 185.199.111.153:443: i/o timeout
2019/02/18 14:07:16 http: proxy error: dial tcp 185.199.111.153:443: i/o timeout

If I ignore some important steps?

rodrigo-brito commented 5 years ago

Hi @JackTiger, the application uses static files from https://go-city.github.io. Were you connected in the internet during the tests?

JackTiger commented 5 years ago

I have connected to the internet. Can I download the application uses static files manual? By the way, Can I direct analysis local directory path using gocity?

@rodrigo-brito

rodrigo-brito commented 5 years ago

It is possible to analysis if your repository is stored inside GOPATH. The static files (Front-end) are not present in application, but it can be improved easily.

rodrigo-brito commented 5 years ago

The application works fine in Linux/Mac. Are you using windows, right? I will try to test it on a virtual machine later and report to you!

JackTiger commented 5 years ago

@rodrigo-brito Yes I test in windows system. But I test in linux in the early, but I got the error:

http: proxy error: x509: certificate signed by unknown authority.
/usr/bin/xdg-open: line 461: links2: command not found
/usr/bin/xdg-open: line 461: links: command not found
/usr/bin/xdg-open: line 461: lynx: command not found
my linux system env is as below:
3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

so I think the application uses static files can be intergeted in gocity repository, that is the best way to use this function local.

rodrigo-brito commented 5 years ago

It is failing to open your browser (The command open the browser automatically). If you access the URL directly, it works? http://localhost:4000/#/github.com/adohe/etcd-dashboard

rodrigo-brito commented 5 years ago

I agree, the integration of static files can help a lot this process.

JackTiger commented 5 years ago

Yes, I access the URL directly, but it does not work, so I do not know what can I do.

JackTiger commented 5 years ago

I suggest release a version that has the integration of static files, so the user can install and use directly.

JackTiger commented 5 years ago

By the way, I think gocity can calculate scores of the golang project, the result can be one of the indicators to evaluate code quality. That is very great! @rodrigo-brito

JackTiger commented 5 years ago

I hava a question. Now gocity only support show the path beginning with github.com url? not the local gopath directory.

I just test home. I found I can connect to the internet. But I find I can only show the project beginning with github.com in my gopath. At the same time, when I open gocity local, If I want to redirect the file in the gocity web, I fount it directly link to github website not my local gopath code. @rodrigo-brito

rodrigo-brito commented 5 years ago

Yes, the code location is based on github.com/... URL. The code retrieving for local files is a good feature. But, the browser may not work as expected, maybe it will be possible only with a external editor.

rodrigo-brito commented 5 years ago

Hi @JackTiger, now the static files are completly embedded on binary. Make a new try and give a feedback.

rodrigo-brito commented 5 years ago

I'm closing it for now. But it is working for private repositories. If a new issues appear, please comment bellow to reopen it.