diff --git a/.deepsource.toml b/.deepsource.toml index 6721085..7683188 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -25,10 +25,11 @@ test_patterns = [ [[analyzers]] name = "go" +enabled = true [analyzers.meta] - import_root = "github.com/purpleclay/gitz" + import_root = "github.com/purpleclay/nsv" [[analyzers]] -name = "secret" +name = "secrets" enabled = true diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index ea13ae9..a8bae85 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,29 @@ -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib +# Ignore everything and selectively allow files +* -# Test binary, built with `go test -c` -*.test +# Allow project files +!.deepsource.toml +!.github/**/* +!.gitignore +!.golangci.yaml +!.goreleaser.yaml +!CODEOWNERS +!CODE_OF_CONDUCT.md +!htmltest.yml +!LICENSE +!mkdocs.yml +!README.md +!Taskfile.yaml -# Output of the go coverage tool, specifically when used with LiteIDE -*.out +# Allow Nix files +!.envrc +!flake.nix +!flake.lock -# Dependency directories (remove the comment below to include it) -# vendor/ +# Allow Go files +!*.go +!go.sum +!go.mod -# Mkdocs -.cache/ -site/ - -# VSCode -.vscode/ +# Recurse through sub-directories applying the same patterns +!*/ diff --git a/LICENSE b/LICENSE index 57cac93..ac33854 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Purple Clay +Copyright (c) 2023 - 2024 Purple Clay Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Taskfile.yml b/Taskfile.yaml similarity index 100% rename from Taskfile.yml rename to Taskfile.yaml diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..0b2278f --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1715534503, + "narHash": "sha256-5ZSVkFadZbFP1THataCaSf0JH2cAH3S29hU9rrxTEqk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2057814051972fa1453ddfb0d98badbea9b83c06", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c23b445 --- /dev/null +++ b/flake.nix @@ -0,0 +1,27 @@ +{ + description = "Write fluent interactions to Git. Programmatically crafting git commands becomes a breeze!"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + with pkgs; + { + devShells.default = mkShell { + buildInputs = [ + git + go + gofumpt + golangci-lint + go-task + ]; + }; + } + ); +} diff --git a/log.go b/log.go index e5ac875..869a507 100644 --- a/log.go +++ b/log.go @@ -265,6 +265,8 @@ func parseLog(log string) []LogEntry { for scanner.Scan() { // Expected format of log from using the --online format is: if hash, msg, found := strings.Cut(scanner.Text(), " "); found { + msg = cleanLineEndings(msg) + entries = append(entries, LogEntry{ Hash: hash, AbbrevHash: hash[:7], diff --git a/log_unix.go b/log_unix.go new file mode 100644 index 0000000..97985d6 --- /dev/null +++ b/log_unix.go @@ -0,0 +1,10 @@ +//go:build !windows +// +build !windows + +package git + +import "strings" + +func cleanLineEndings(log string) string { + return strings.ReplaceAll(log, "\r\n", "\n") +} diff --git a/log_windows.go b/log_windows.go new file mode 100644 index 0000000..66ac28e --- /dev/null +++ b/log_windows.go @@ -0,0 +1,9 @@ +//go:build windows +// +build windows + +package git + +func cleanLineEndings(log string) string { + // Mixed line endings don't appear within Windows + return log +}