Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@
end_of_line = lf
insert_final_newline = true
charset = utf-8

# Nix and cargo generate these lock files.
[{devenv.lock,Cargo.lock}]
max_line_length = off
indent_size = unset
insert_final_newline = unset
end_of_line = unset
7 changes: 7 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# shellcheck shell=bash
if has devenv; then
eval "$(devenv direnvrc)"
use devenv
else
echo "Cannot find devenv. Install it: https://devenv.sh/getting-started/" >&2
fi
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
devenv.lock linguist-generated=true
Cargo.lock linguist-generated=true
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
pull_request:
push:
branches: [main]

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Lint and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: cachix/install-nix-action@v31
- uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: cargo-${{ runner.os }}-
- uses: cachix/cachix-action@v17
with:
name: devenv

- name: Install devenv
run: nix profile add nixpkgs#devenv

- name: Run git-hooks
run: devenv tasks run devenv:git-hooks:run

- name: Run tests
run: devenv shell -- cargo test
34 changes: 0 additions & 34 deletions .github/workflows/rust.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
/target

# Nix / devenv
/.devenv/
/.devenv.flake.nix
/devenv.local.nix
/.pre-commit-config.yaml
/.direnv/
2 changes: 1 addition & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

** Description

This is a small tool that helps to list the files you have changed (added/modifed/removed) in your git branch.
This is a small tool that helps to list the files you have changed (added/modified/removed) in your git branch.

This can be useful when working with large repositories, as you can run tools on a specific subset of files instead of the entire repository.
It can be easily integrated into your workflow to streamline your development process.
Expand Down
103 changes: 103 additions & 0 deletions devenv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{ pkgs, ... }:

{
packages = [
pkgs.cargo-outdated
pkgs.pkg-config
pkgs.openssl
pkgs.zlib
];

languages.rust = {
enable = true;
channel = "nixpkgs";
};

git-hooks.hooks = {
rustfmt.enable = true;
clippy = {
enable = true;
settings = {
denyWarnings = true;
extraArgs = "--all-targets";
};
};
editorconfig-checker.enable = true;
statix.enable = true;
deadnix.enable = true;
nixfmt.enable = true;
check-toml.enable = true;
check-yaml.enable = true;
check-merge-conflicts.enable = true;
typos.enable = true;
ripsecrets.enable = true;
shellcheck.enable = true;
shfmt.enable = true;
};

enterTest = ''
cargo test
'';
}
10 changes: 10 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
strict_ports: true

inputs:
git-hooks:
url: github:cachix/git-hooks.nix
inputs:
nixpkgs:
follows: nixpkgs
nixpkgs:
url: github:cachix/devenv-nixpkgs/rolling
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn matches_to_options(matches: ArgMatches) -> Options {
}

#[cfg(test)]
pub fn get_options_from(cmd: &String) -> Result<Options> {
pub fn get_options_from(cmd: &str) -> Result<Options> {
let args = cmd.split(' ');

let matches = command().try_get_matches_from(args)?;
Expand Down
2 changes: 1 addition & 1 deletion src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn uncommitted_changes(repo: &Repository) -> Result<Vec<String>> {
.collect()
}

fn find_tree(repo: &Repository, oid: Oid) -> Result<Tree> {
fn find_tree(repo: &Repository, oid: Oid) -> Result<Tree<'_>> {
repo.find_commit(oid)?
.tree()
.with_context(|| format!("Failed to find tree for {}", oid))
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn execute(options: Options) -> Result<()> {
}

#[cfg(test)]
pub fn from(cmd: &String) -> Result<()> {
pub fn from(cmd: &str) -> Result<()> {
let options = cli::get_options_from(cmd)?;

execute(options)
Expand Down
4 changes: 3 additions & 1 deletion tests/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use stdio_override::StdoutOverride;
use tempfile::NamedTempFile;
use uuid::Uuid;

// The tests use only some functions of the binary. Do not report the other functions as dead code.
#[allow(dead_code)]
#[path = "../src/main.rs"]
mod main;

Expand Down Expand Up @@ -47,7 +49,7 @@ fn init_directory(world: &mut GitWorld) {
let dir = env::temp_dir();
let uuid = Uuid::new_v4().to_string();

let name = format!("git-changed-{}", &uuid);
let name = format!("git-changed-{uuid}");
let directory = dir.join(name);

fs::create_dir_all(directory.clone()).expect("Could not create directory!");
Expand Down
6 changes: 3 additions & 3 deletions tests/features/non-empty.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ Feature: Non-empty git repository
"""
"""

Rule: With uncommited changes
Rule: With uncommitted changes

Background: With uncommited changes
Background: With uncommitted changes
When the user executes the command: "dd if=/dev/random of=README.md count=1"

Scenario: It displays the uncommited changes
Scenario: It displays the uncommitted changes
When the user executes the tool like: "git-changed"
Then it succeeds with the following output
"""
Expand Down
Loading