Coder Social home page Coder Social logo

nickgerace / gfold Goto Github PK

View Code? Open in Web Editor NEW
270.0 6.0 20.0 1.37 MB

CLI tool to help keep track of your Git repositories, written in Rust

Home Page: https://crates.io/crates/gfold

License: Apache License 2.0

Rust 100.00%
rust rust-cli git git-cli cli

gfold's Introduction

gfold

latest release tag crates.io version license build status

gfold is a CLI tool that helps you keep track of multiple Git repositories.

A GIF showcasing gfold in action

If you'd prefer to use the classic display mode by default, and avoid setting the flag every time, you can set it in the config file (see Usage section).

Description

This app displays relevant information for multiple Git repositories in one to many directories. It only reads from the filesystem and will never write to it. While this tool might seem limited in scope and purpose, that is by design.

By default, gfold looks at every Git repository via traversal from the current working directory. If you would like to target another directory, you can pass its path (relative or absolute) as the first argument or change the default path in the config file.

After traversal, gfold leverages rayon to perform concurrent, read-only analysis of all Git repositories detected. Analysis is performed by leveraging the git2-rs library.

Usage

Provide the -h/--help flag to see all the options for using this application.

# Operate in the current working directory or in the location provided by a config file, if one exists.
gfold

# Operate in the parent directory.
gfold ..

# Operate in the home directory (first method).
gfold $HOME

# Operate in the home directory (second method).
gfold ~/

# Operate with an absolute path.
gfold /this/is/an/absolute/path

# Operate with a relative path.
gfold ../../this/is/a/relative/path

Config File

If you find yourself providing the same arguments frequently, you can create and use a config file. gfold does not come with a config file by default and config files are entirely optional.

How does it work? Upon execution, gfold will look for a config file at the following path on macOS, Linux and similar operating systems.

$HOME/.config/gfold.toml

On Windows, the lookup path will be in a similar location.

{FOLDERID_Profile}\.config\gfold.toml

For config file creation, you can use the --dry-run flag to print valid TOML. Here is an example config file creation workflow on macOS, Linux and similar platforms:

gfold -d classic -c never ~/ --dry-run > $HOME/.config/gfold.toml

Here are the contents of the resulting config file:

path = '/home/neloth'
display_mode = 'Classic'
color_mode = 'Never'

Let's say you created a config file, but wanted to execute gfold with entirely different settings and you want to ensure that you do not accidentally inherit options from the config file. In that scenario you can ignore your config file by using the -i flag.

gfold -i

You can restore the config file to its defaults by using the same flag.

gfold -i > $HOME/.config/gfold.toml

In addition, you can ignore the existing config file, configure specific options, and use defaults for unspecified options all at once. Here is an example where we want to use the classic display mode and override all other settings with their default values:

gfold -i -d classic > $HOME/.config/gfold.toml

You can back up a config file and track its history with git. On macOS, Linux, and most systems, you can link the file back to a git repository.

ln -s <path-to-repository>/gfold.toml $HOME/.config/gfold.toml

Now, you can update the config file within your repository and include the linking as part of your environment setup workflow.

Installation

Packaging status

Homebrew

You can use Homebrew to install gfold with a choice of two methods.

Core (macOS and Linux)

gfold is now available in the core formulae! However, you may run into a naming collision on macOS if coreutils is installed via brew. See the troubleshooting section for a workaround and more information.

brew install gfold

Tap (macOS only)

The tap is still available if you would like to use it. This is subject to change.

brew install nickgerace/nickgerace/gfold

Arch Linux

You can use pacman to install gfold from the extra repository.

pacman -S gfold

Nix and NixOS

You can install gfold from nixpkgs:

nix-env --install gfold

If you are using flakes, you can install using the nix command directly.

nix profile install "nixpkgs#gfold"

Cargo

You can use cargo to install the crate on almost any platform.

cargo install gfold

Use the --locked flag if you'd like Cargo to use Cargo.lock.

cargo install --locked gfold

Keeping the crate up to date is easy with cargo-update.

cargo install cargo-update
cargo install-update -a

Download a Binary

If you do not want to use one of the above installation methods and do not want to clone the repository, you can download a binary from the releases page. For an example on how to do that, refer to the manual install guide.

Build From Source

If you would like an example on how to build from source, refer to the manual install guide.

Preferred Installation Method Not Listed?

Please file an issue!

Compatibility

gfold is intended to be ran on any tier one Rust ๐Ÿฆ€ target. Please file an issue if your platform is unsupported.

Usage as a Library

There are two ways to use gfold as a "library".

  1. Use the libgfold crate that powers gfold
  2. Consume valid JSON results from gfold -d json (not a library, but useful for non-Rust applications)

Troubleshooting and Known Issues

If you encounter unexpected behavior or a bug and would like to see more details, please run gfold with the following environment variables:

# You may also want to add relevant arg(s) and flag(s).
RUST_BACKTRACE=1 RUST_LOG=debug gfold

If the issue persists, please file an issue.

Tuning Environment Variables

Since RUST_BACKTRACE and RUST_LOG do not have gfold-specific behaviors, you can adjust them just as you would in other projects to aid investigation. Please attach relevant logs from execution with sensitive bits redacted in order to help resolve your issue.

Coreutils Collision on macOS

If fold from GNU Coreutils is installed on macOS via brew, it will be named gfold. You can avoid this collision with shell aliases, shell functions, and/or PATH changes. Here is an example with the o dropped from gfold:

alias gfld=$HOME/.cargo/bin/gfold

Upstream libgit2 Issue

If you are seeing unsupported extension name extensions.worktreeconfig or similar errors, it may be related to libgit2/libgit2#6044.

This repository's tracking issue is #205.

Community

For more information and thanks to contributors, users, and the "community" at large, please refer to the THANKS file.

gfold's People

Contributors

acksld avatar bors[bot] avatar dylan-dpc avatar jrcichra avatar nickgerace avatar orhun avatar soutrikbandyopadhyay 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

gfold's Issues

Recover as many errors as possible

There are many panic scenarios in gfold currently. This issue aims to recover on as many errors as possible, if not all of them.

Ideally, we would like main.rs to make every decision on how to handle the errors, and avoid panics in the library.

Panics on Bare Repo

Hey! I came to your tool from ๐Ÿ“ How I Read "The Rust Programming Language".

I noticed that the binary panics on bare repositories.

image

โžœ  tmp RUST_BACKTRACE=full /Users/kyle/.cargo/bin/gfold
thread 'main' panicked at 'failed get statuses: cannot status. This operation is not allowed against bare repositories.; class=Repository (6); code=BareRepo (-8)', src/gfold.rs:71:27
stack backtrace:
   0:        0x1067e61fe - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h13e6f26430148ff2
   1:        0x1068038cc - core::fmt::write::h45a9bd04db15c24f
   2:        0x1067e3629 - std::io::Write::write_fmt::h8ae61696f13218d5
   3:        0x1067e7e75 - std::panicking::default_hook::{{closure}}::hc98fe2390b6284e5
   4:        0x1067e7bb2 - std::panicking::default_hook::h9a63cea866a4c14a
   5:        0x1067e83d5 - std::panicking::rust_panic_with_hook::h4d446ca45c8e1faa
   6:        0x1067e7fa2 - rust_begin_unwind
   7:        0x10680f1db - std::panicking::begin_panic_fmt::h0f7b83f993394bc5
   8:        0x1066fedb0 - gfold::gfold::walk_dir::h7ce7a797048a9dd9
   9:        0x1066fc1b9 - gfold::main::h9a34aaa0573dc180
  10:        0x1066fc4e6 - std::rt::lang_start::{{closure}}::h1185fef6ccb1df63
  11:        0x1067e86a9 - std::rt::lang_start_internal::hecbcda5e1a75a865
  12:        0x1066fc4d9 - main

Steps to reproduce

$ mkdir repos
$ cd repos
$ git clone --bare https://github.com/octocat/Spoon-Knife
$ gfold

Move from library-driven structure to application-driven structure

Describe the issue:

Since gfold's library API is not consumed by any other application, nor is it fully designed to be, we should revert back to an application-driven structure to reduce complexity. This may also enable logging to return in a fully capacity since all code will not be library code. Moreover, this would likely result in the removal of lib.rs.

Is this a bug report, feature request, or another type of issue?

refactor

Are you using Windows, macOS, Linux, or another OS?

n/a

How did you obtain the application?

n/a

Paste the output of gfold -V:

n/a

[Feature Request]

  • in the table rows, one could have a clickable repository url
  • and of course a state against the local repo : upgradable (5 commits)

with colors, in term of importance (new version > commits > minor commit > ...)

my 2 cents, I wanted to build the same tool, and I'm surprised how compact the code is, bravo!

Move from StructOpt to Clap v3 (beta)

Describe the issue:

Since Clap v3 will be the successor to StructOpt and Clap v3 beta releases have been relatively stable, we should move to using Clap v3 (beta).

Is this a bug report, feature request, or another type of issue?

refactor

Are you using Windows, macOS, Linux, or another OS?

n/a

How did you obtain the application?

n/a

Paste the output of gfold -V:

n/a

Library should not log

The gfold library should not log. The application should, if needed. Since the architecture is mainly a small CLI backed by a library, logging might even be removed entirely.

In addition, the logging from gfold 1.2.1 and before was very opinionated and included text that could become out of date or be incorrect.

Add `-k` flag to give kubectl-like output

Describe the issue:

Add -k flag to give kubectl-like output. This involves combining all results into one table with headers similar to kubectl.

Is this a bug report, feature request, or another type of issue?

feature request

Are you using Windows, macOS, Linux, or another OS?

all (maintainer)

How did you obtain the application?

all (maintainer)

Paste the output of gfold -V:

% gfold -V
gfold 1.4.0

Minimize issue filing process

Minimize issue filing process to have as minimal questions as possible.

OS type

Exact version number would no longer be required (such as Windows 10 2004, macOS 11.0, and Ubuntu 20.10

Prebuilt-binary or not

High-level obtainment method required (ex: build from source, crates.io, GitHub release download, etc.)

Type of request

RFE, bug, other.

Switch to structopt for the CLI library

We are running unversioned clap-rs, grabbing the latest from its main branch. It may be worth considering using structopt until clap-rs v3 releases (even after that too).

Add small backtrace to get file and line number

We do not need an extended backtrace. gfold should remain lightweight. Since the codebase is relatively small, the file and line number should be enough to help determine the cause of the error. Custom errors are probably not necessary.

Replace unnecessary panics with returned errors

Describe the issue. Feel free to be descriptive.

Instead of using expect and panic frequently, return the errors instead. It would be preferred to recover on many of these errors rather than simply "returning" them from the calling function, but this is a good first step.

What are you attempting to do, and/or what did you expect? In other words, what is the motivation and context to this issue?

The motivation is to clean up the codebase to return nearly all panic scenarios to main.rs. This is stepping stone towards recovering on more errors.

Is this a bug report, feature request, or another type of issue? If this is a bug report, describe how to reproduce the issue.

Feature enhancement

Are you using a pre-built binary? If not, please specify.

Yes

What OS are you using, and at what version number?

All OSes with corresponding GitHub releases, using the latest major version of each

What CPU architecture are you using? If you do not know, it is most likely amd64 or x86_64.

amd64

Additional information (optional)

None.

Add release action

Describe the issue:

Add release action, but don't add hosted binaries yet. Using a package manager is always ideal.

Is this a bug report, feature request, or another type of issue?

feature (meta)

Are you using Windows, macOS, Linux, or another OS?

n/a

How did you obtain the application?

n/a

Paste the output of gfold -V:

n/a

Add GitHub releases with binaries

We should add binaries for every tagged release with the minimum being...

  • Linux: linux-gnu-amd64
  • macOS: darwin-amd64
  • Windows 10: windows-amd64

There are no results to display

Describe the issue.

It's weird, I don't seem to see any results. with strace I see that some git files are read.

~/dev
โฏ gfold
There are no results to display.

gfold 0.8.0

Is this a bug report, feature request, or another type of issue?

bug

Are you using Windows, macOS, Linux, or another OS?

Linux

Are you using a pre-built binary? If not, how did you obtain gfold?

cargo install gfold

Refactor library into driver and util files

Description

Refactor library into driver and util files. This will help organize the gfold API for future refactors and changes.

Environment Details

Please feel free to add any additional details beyond the questions below.

Is this a bug report, feature request, or another type of issue?

Feature request

Are you using Windows, macOS, Linux, or another OS?

Windows, macOS, and Linux on amd64

Are you using a pre-built binary? If not, how did you obtain gfold?

Build from source

Arch Linux (AUR) Packages

Hi,
I came across your project and I liked it. It looks promising for sure. ๐Ÿš€
I'm also a Rust developer and I maintain AUR packages in my spare time. So I created the following packages for the installation of gfold on Arch Linux and other distributions that support installing packages from AUR:

Installation can be made simply by a AUR helper such as yay. (e.g: yay -S gfold)

Feel free to update your documentation regarding to the AUR packages and installation. (I would propose a PR if requested)

Take care,
orhun.

Release version 1.0.0

Starting this issue just to keep track of release 1.0.0. This version will be considered "stable" for at least one binary, probably macos-amd64.

Remove gfld and consolidate optimizations into gfold

Summary

gfld was an experiment to try to make a smaller, and faster, alternative to gfold. The results have been that gfold is much faster, despite it's larger size. Thus, the following should happen:

  • Removal of gfld
  • Learned optimizations to be integrated into gfold
  • Return to a single crate repository structure (has the bonus benefit of being easier to maintain)

Details

  • On average, the runtime speed of gfld 1.0.4 is ~105% slower than the runtime speed of gfold 1.0.4
  • The binary size of gfld 1.0.4 is about ~40% smaller than gfold 1.0.4

Estimates

  • gfold can potentially have its binary size reduced to ~60% of the size of gfold 1.0.4
  • gfold runtime speeds will either be the same, better, or more consistent with proposed optimizations

Suspend support for Linux MUSL binaries

Supporting MUSL requires using Docker at the moment. Since there are few users of gfold at the moment, we should suspend usage to minimize bloat in the CI pipeline.

However, if there's user interest, we should consider adding back statically-linked Linux (amd64) binaries to the pipleline.

Add Cargo.lock to workspace root

Describe the issue.

According to the cargo workspace documentation, all packages should share a common Cargo.lock file which should be present in the workspace root.

All packages share a common Cargo.lock file which resides in the workspace root.

Also AUR packages will become non-reproducible due to this issue since --locked flag causes the build to fail. (because Cargo.lock doesn't exist in the workspace root)

==> Starting build()...
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   /build/gfold/src/gfold-1.0.0/gfld/Cargo.toml
workspace: /build/gfold/src/gfold-1.0.0/Cargo.toml
    Updating crates.io index
error: the lock file /build/gfold/src/gfold-1.0.0/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, use the --offline flag.
==> ERROR: A failure occurred in build().

Solution is simply removing Cargo.lock from .gitignore and pushing it.

Is this about gfold, gfld, or both?

Both, about Cargo workspaces.

Is this a bug report, feature request, or another type of issue?

Bug report.

Paste the output of the relevant application(s).

# to reproduce the build error
git clone "https://aur.archlinux.org/gfold-git"
cd gfold-git/
extra-x86_64-build

Fix is_unpushed to use correct remote

Describe the issue.

The "origin" resolved during is_unpushed is from the main remote branch, and not the remote of the local branch being tracked. Regardless of the fix, we may need to check if a remote exists for the local branch.

Is this a bug report, feature request, or another type of issue?

bug report

Are you using Windows, macOS, Linux, or another OS?

all supported platforms

Are you using a pre-built binary? If not, how did you obtain gfold?

build from source

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.