Giter Site home page Giter Site logo

gostatus's Introduction

gostatus

Go Reference

gostatus is a command line tool that shows the status of Go repositories.

Installation

go install github.com/shurcooL/gostatus@latest

Usage

Usage: gostatus [flags] [packages]
       [newline separated packages] | gostatus -stdin [flags]
  -c	Compact output with inline notation.
  -debug
    	Cause the repository data to be printed in verbose debug format.
  -f	Force not to verify that each package has been checked out from the source control repository implied by its import path. This can be useful if the source is a local fork of the original.
  -stdin
    	Read the list of newline separated Go packages from stdin.
  -v	Verbose mode. Show all Go packages, not just ones with notable status.

Examples:
  # Show status of all packages.
  gostatus all

  # Show status of package in current directory.
  gostatus

  # Show status of all dependencies (recursive) of package in current dir.
  go list -deps | gostatus -stdin -v

Legend:
  ? - Not under version control or unreachable remote
  b - Non-default branch checked out
  * - Uncommited changes in working dir
  + - Update available
  - - Local revision is ahead of remote revision
  ± - Update available; local revision is ahead of remote revision
  ! - No remote
  / - Remote repository not found (was it deleted? made private?)
  # - Remote path doesn't match import path
  $ - Stash exists

Examples

# Show status of all packages.
$ gostatus all

# Show status of package in current directory.
$ gostatus

# Show status of specified package.
$ gostatus import/path

# Show status of all dependencies (recursive) of package in current dir.
$ go list -deps | gostatus -stdin -v

# Show status of all dependencies (recursive) of specified package.
$ go list -deps import/path | gostatus -stdin -v

Sample Output

$ gostatus all
  +  github.com/dchest/uniuri/...
	+ Update available
  +  github.com/syndtr/goleveldb/...
	+ Update available
b    github.com/shurcooL/go-goon/...
	b Non-default branch checked out
 *   github.com/shurcooL/Conception-go/...
	* Uncommited changes in working dir
  #  github.com/russross/blackfriday/...
	# Remote path doesn't match import path
   $ github.com/microcosm-cc/bluemonday/...
	$ Stash exists
  /  github.com/go-forks/go-pkg-xmlx/...
	/ Remote repository not found (was it deleted? made private?):
		remote repository not found:
		exit status 128: remote: Repository not found.
		fatal: repository 'https://github.com/go-forks/go-pkg-xmlx/' not found

There are a few observations that can be made from that sample output.

  • uniuri and goleveldb repos are out of date, I should update them via go get -u.
  • go-goon repo has a non-default branch checked out, I should be aware of that.
  • Conception-go repo has uncommited changes. I should remember to commit or discard the changes.
  • blackfriday repo has a remote that doesn't match its import path. It's likely my fork in place of the original repo for temporary development purposes.
  • bluemonday repo has a stash. Perhaps I have some unfinished and uncommited work that I should take care of.
  • go-pkg-xmlx repo was not found. Perhaps the repository was deleted or made private.
  • All other repos are up to date and looking good (they're not displayed unless -v is used).

Directories

Path Synopsis
status Package status provides a func to check if two repo URLs are equal in the context of Go packages.

License

gostatus's People

Contributors

dmitshur avatar kjk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gostatus's Issues

Remote URL mismatch message can be misleading due to different URL protocols.

Originally reported by @mafredri in #37 (comment):

the error message should be made less confusing. Instead of:

# Remote URL ([email protected]:mafredri/go-gaussian.git) doesn't match repo URL inferred from import path (https://github.com/mafredri/go-gaussian)

It would say:

# Remote URL ([email protected]:mafredri/go-gaussian.git) doesn't match repo URL inferred from import path ([email protected]:mafredri/go-gaussian)

By matching the protocol used, the user would not be lead as much astray as to why the error is popping up.

Errors when `go get`ting gostatus

Hi

I tried to install your software but I get the following errors:

% mkdir gostatus; GOPATH=gostatus go get github.com/shurcooL/gostatus
# gist.github.com/5286084.git
open gostatus/src/gist.github.com/5286084.git/main.go: No such file or directory
# gist.github.com/5892738.git
open gostatus/src/gist.github.com/5892738.git/main.go: No such file or directory
# gist.github.com/7519227.git
open gostatus/src/gist.github.com/7519227.git/main.go: No such file or directory

In case you need it:

% go version
go version go1.2 darwin/amd64

Regards,

m.

Remote SSH URL doesn't match HTTP URL for repo

I just tried out this tool and got to say it's pretty awesome! One thing I noticed though that it doesn't handle any of my [email protected]:name/repo.git URLs. For example:

  #  github.com/mafredri/go-gaussian/...
    # Remote URL ([email protected]:mafredri/go-gaussian.git) doesn't match repo URL inferred from import path (https://github.com/mafredri/go-gaussian)

In my opinion this should be a match since they are essentially the same repo.

Nondeterministic output

I am getting very nondeterministic output when running gostatus repeatedly. On the one hand, for packages a/b and a/c, where both are in the same git repository, gostatus sometimes reports one and sometimes the other.

There's a bigger issue, however: Sometimes I get N results back, sometimes M (where N != M).

I ran gostatus 1000 times with

for i in {1..1000}; do ( go list honnef.co/... | gostatus > $i.txt ) &; done

and then evaluated the number of entries for each run and ended up with the following distribution (first column how often, second column how many entries):

    252 17
    234 18
    164 16
    136 19
     84 15
     69 20
     28 21
     22 14
     10 22
      1 23

Running gostatus with the --all flag consistently reports 29 entries.

Lots of "Remote path doesn't match import path"

So, the vast majority of my repos have the # or "Remote path doesn't match import path" message.

$ cd ~/go/src
$ gostatus -c all
  ....
  #  github.com/spf13/afero/...
  #  github.com/spf13/cast/...
  #  github.com/spf13/fsync/...
  #  github.com/spf13/cobra/...
  #  github.com/spf13/hugo/...
  ....

But, they do match....

$ cd $GOPATH/src/github.com/spf13/hugo
$ git remote -v
origin  [email protected]:spf13/hugo (fetch)
origin  [email protected]:spf13/hugo (push)

So what is this message actually saying?

Support Go import path remote verification.

With Go 1.4, go get -u will now check and complain if the remote isn't what it expects.

Currently, gostatus does a half-baked job of displaying that in the form of # symbol that replaces other remote-related +, - and ! symbols.

In my local tree, I have a version that performs full verification.

One thing I'm unsure about... go get -u offers a flag -f that disables such verification. I currently support that flag too, but I wonder if I should? Is it a good idea?

Don't display `+` for repos with no remote.

The current logic for displaying + is:

if w.VcsLocal.LocalRev != w.VcsRemote.RemoteRev {
    out += "+"
} else {
    out += " "
}

This should be changed to:

if w.VcsRemote.RemoteRev != "" && w.VcsLocal.LocalRev != w.VcsRemote.RemoteRev {
    out += "+"
} else {
    out += " "
}

That way, repos that have no remote set will not show +, since there really isn't an update available.

Thanks @dominikh for reporting. Extracted from #11.

Present repositories with more than 1 Go package inside in a better way.

gostatus currently lists one Go package per repo (if there are many, one is chosen non-deterministically due to concurrency).

To make this deterministic, I can think of a few strategies:

  • Always show the root vcs folder, instead of full import path.
  • Always try to show the first import path (alphabetically) of the vcs repo.
  • Always show all import paths per each vcs repo (how to make this non-verbose, some repos have 30+ Go packages).

Extracted from #11. Considering this human presentation change suggested by @dominikh.

Remove gists

Having a list of gists (with no proper names to identify) in my global package list is annoying. A lot.

Please do it.

Thanks

Repo URLs should probably be compared with the protocol removed

I tend to configure local copies of my own Github repos with the remote being [email protected]:siebenmann/repo, so that I push to Github via SSH. Right now this makes gostatus think that the remote path doesn't match the local path, since the official remote path it picks is https://github.com/siebenmann/repo. The best solution for this seems likely to be a protocol independent comparison of the remote path.

(By the way, thank you for gostatus. It's a great tool and a nice complement to Go-Package-Store.)

Print something when there's nothing to report

Currently in default verbose mode when there is nothing to report, nothing is printed. That gives the impression that the program didn't work at all.

Instead it could print something like:

github.com/kjk/gostatus/...
    This checkout is up to date!

Provide more detailed error message for mismatched import paths

Using the latest version of gostatus:

Krzysztofs-MacBook-Pro:quicknotes kjk$ gostatus .
github.com/kjk/quicknotes/...
    # Remote path doesn't match import path

It would be good if error message printed both paths.

As an additional bonus, it would be good to document most common cases for such error somewhere (a wiki, a gist, a blog post) and also print a link to this document as part of error message. As it stands, I have no clue why this is happening, how to debug it further or whether it's a bug, an omission or a design decision.

The underlying reason might be same as issue #30 or maybe it's because it's as private repo that I git clone-d as opposed to go get-ted.

An idea for more user-friendly human-readable output (at the cost of verbosity).

This is an idea for how to make the default human-readable output of gostatus more friendly towards people seeing/using the tool that are not extremely familiar with it (like I am). Thanks to @audreylim for the suggestion!

Current Output

The current output puts each repository on a single line, prepended with 4 possible cryptic symbols like:

  +  github.com/dchest/uniuri/...
  +  github.com/syndtr/goleveldb/...
b    github.com/shurcooL/go-goon/...
 *-  github.com/shurcooL/Conception-go/...
  #  github.com/russross/blackfriday/...
   $ github.com/microcosm-cc/bluemonday/...

Unless you've created this tool (like I did), or use it nearly daily (like I often do), the above output will probably make no sense unless you spend the time to look at the legend (which you'll hopefully find in gostatus -help or in README, instead of quitting in frustration):

Legend:
  ???? - Not under (recognized) version control
  b - Non-master branch checked out
  * - Uncommited changes in working dir
  + - Update available
  - - Local revision is ahead of remote (need to push?)
  ! - No remote
  # - Remote path doesn't match import path
  $ - Stash exists

Proposed Output

Instead, I could make the default output more friendly towards use without having to memorize cryptic symbols. It's inspired by how I produce output in another tool binstale.

The general idea is to print the repo import path first, and then underneath it write short bullet points for each interesting property of the repo (if there's nothing interesting, the entire repository is omitted from output, unless -v flag is used). Something like this:

github.com/dchest/uniuri/...
    update is available: commit 12345abc (you have 11111def)
github.com/syndtr/goleveldb/...
    update is available: commit 67890bce (you have 22222fed)
github.com/shurcooL/go-goon/...
    non-default branch is checked out: dev (default is master)
github.com/shurcooL/Conception-go/...
    dirty working tree, including files: main.go highligt.go
    local revision ahead of remote: commit 23456be (remote has 112233ced)
github.com/russross/blackfriday/...
    remote doesn't match import path: https://github.com/shurcooL/blackfriday
github.com/microcosm-cc/bluemonday/...
    stash(es) exist: 2 stashes

This is also inspired by the output of git status. It uses easy to understand language to explain the status of a git repository, rather than cryptic symbols.

If there's a huge demand, I can preserve the current dense output mode under an optional flag, but I think this new presentation mode will be an overall improvement to users of gostatus.

I welcome initial feedback. I'll also implement this on a branch and try it myself first, and see how I like it.

Support JSON Output

It would be great if this tool supported a flag for JSON output, so that other tools could reason over the results more easily.

Proposal: change CLI to take packages as parameters, rather than from stdin.

Does anyone (besides me) actually use this tool?

Currently, the number 1 most common use case (for me) is:

go list all | gostatus

Or, more generally:

go list [some parameters to go list] | gostatus [flags to gostatus]

What if I changed the CLI so that gostatus gets a list of packages in the same way as go list (via github.com/kisielk/gotool), as a parameter:

gostatus [flags to gostatus] [some parameters to go list]

The only disadvantage I see is no longer being able to do things like go list all | grep -v something/private | gostatus or other things that pipes let you do. Other than that, it would be identical. Also, gostatus could be made to imply gostatus all.

Any thoughts? Objections?

handle version tag

Hi,

I d like very much it also handles tags
to detect repository that are currently in
RC state such as beta / alpha,
so that i can have better overview of which repo has pending release.

As example i have this repo here (https://github.com/mh-cbon/emd/releases)
with pending release for +10 days, likely i will forget about it if i m into some rush.

Would a patch using Masterminds/semver suitable for you ?

Detect and report when remote repository is not found (deleted? made private?).

It'd be nice to do this.

For example, this recently happened to https://github.com/go-forks/go-pkg-xmlx, which is 404 now. This is the output I saw:

$ gostatus -c all | grep -v /vendor/
  +  github.com/fatih/color/...
  +  github.com/gogo/protobuf/...
  +  github.com/golang/lint/...
2017/02/14 20:04:59 github.com/go-forks/go-pkg-xmlx: exit status 128: remote: Repository not found.
fatal: repository 'https://github.com/go-forks/go-pkg-xmlx/' not found
  ?  github.com/go-forks/go-pkg-xmlx/...
  +  github.com/gorilla/handlers/...
  +  github.com/jessevdk/go-flags/...
...

But it'd nicer to see:

$ gostatus -c all | grep -v /vendor/
  +  github.com/fatih/color/...
  /  github.com/go-forks/go-pkg-xmlx/...
  +  github.com/gogo/protobuf/...
  +  github.com/golang/lint/...
  +  github.com/gorilla/handlers/...
...

Where / is the symbol used for "remote repository not found" (it's really hard to think of a good one).

Without compact mode -c flag, it'd be:

$ gostatus github.com/go-forks/go-pkg-xmlx/...
  /  github.com/go-forks/go-pkg-xmlx/...
	/ Remote repository not found (was it deleted? made private?):
		remote repository not found:
		exit status 128: remote: Repository not found.
		fatal: repository 'https://github.com/go-forks/go-pkg-xmlx/' not found

The error details come from the following git command:

git ls-remote --symref origin HEAD refs/heads/*

Better presentation for humans...

I literally spent less than 15 seconds coming up with the random characters that represent various states (see Legend). '+' and '*' look kinda similar and may not be the most intuitive.

Perhaps this can be improved? Proposals are welcome.

Making a change should be easy, you just need to modify one func in status/status.go.

A way to just update the outdated?

Current approach is: go list all | gostatus | grep + | cut -c7- | xargs go get -u

Would you be amenable to providing a less complex way to do it, ie, something that doesn't rely on 3 other unix tools to get the job done?

perhaps:

go get -u `go list all | gostatus --updates-only`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.