Skip to content

Commit

Permalink
Simplify reponame util
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Oct 8, 2024
1 parent 053937c commit a7297f5
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ updates:
schedule:
interval: 'weekly'
- package-ecosystem: 'gomod'
directory: '/pkgs/trim-github-user-prefix-for-reponame'
directory: '/pkgs/reponame'
schedule:
interval: 'weekly'
2 changes: 1 addition & 1 deletion .github/workflows/update-flake-lock-and-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
pr-title: 'Bump flake.lock and related dependencies'
optional-run: |
nix run .#bump_completions
nix run .#bump_gomod -- . pkgs/trim-github-user-prefix-for-reponame
nix run .#bump_gomod -- . pkgs/reponame
secrets:
APP_PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }}
6 changes: 3 additions & 3 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ args = [
[tasks.test-go]
dependencies = [
'test-cmd',
'test-pkg-trim-github-user-prefix-for-reponame',
'test-pkg-reponame',
]

[tasks.test-cmd]
Expand All @@ -90,8 +90,8 @@ args = [
'./...',
]

[tasks.test-pkg-trim-github-user-prefix-for-reponame]
cwd = "./pkgs/trim-github-user-prefix-for-reponame"
[tasks.test-pkg-reponame]
cwd = "./pkgs/reponame"
command = 'go'
args = [
'test',
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
"git-resolve-conflict"
"prs"
"nix-hash-url"
"trim-github-user-prefix-for-reponame"
"reponame"
"gredit"
"renmark"
"preview"
Expand Down
4 changes: 1 addition & 3 deletions pkgs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@

prs = import ./prs { inherit pkgs; };

trim-github-user-prefix-for-reponame = import ./trim-github-user-prefix-for-reponame {
inherit pkgs;
};
reponame = import ./reponame { inherit pkgs; };

beedii = pkgs.callPackage ./beedii { };
cozette = pkgs.callPackage ./cozette { };
Expand Down
4 changes: 2 additions & 2 deletions pkgs/posix_shared_functions/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# How to stop blinking cursor in Linux console?
# => https://web-archive-org.translate.goog/web/20220318101402/https://nutr1t07.github.io/post/disable-cursor-blinking-on-linux-console/?_x_tr_sl=auto&_x_tr_tl=ja&_x_tr_hl=ja
let
trim-github-user-prefix-for-reponame = pkgs.callPackage ../trim-github-user-prefix-for-reponame { };
reponame = pkgs.callPackage ../reponame { };
ghqf = pkgs.callPackage ../ghqf { };
fzf-bind-posix-shell-history-to-git-commit-message =
pkgs.callPackage ../fzf-bind-posix-shell-history-to-git-commit-message
Expand All @@ -23,7 +23,7 @@ in
pkgs.writeText "posix_shared_functions.sh" (
''
cdrepo() {
local -r query_repoonly="$(echo "$1" | ${lib.getExe trim-github-user-prefix-for-reponame})"
local -r query_repoonly="$(echo "$1" | ${lib.getExe reponame})"
local -r repo="$(${lib.getExe ghqf} "$query_repoonly")"
if [ -n "$repo" ]; then
cd "$(${lib.getExe pkgs.ghq} list --full-path --exact "$repo")"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ pkgs, ... }:
pkgs.buildGo122Module rec {
pname = "trim-github-user-prefix-for-reponame";
pname = "reponame";
version = "0.0.1";
default = pname;
vendorHash = "sha256-1wycFQdf6sudxnH10xNz1bppRDCQjCz33n+ugP74SdQ=";
Expand Down
5 changes: 5 additions & 0 deletions pkgs/reponame/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/kachick/dotfiles/pkgs/reponame

go 1.22.6

require github.com/google/go-cmp v0.6.0
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
// Can't I use https://github.com/google/go-github or https://github.com/cli/cli for more robust feature?
// They are looks depend on GitHub API, not only for string operations...
func extractRepo(line string) string {
// Using Cut cannot handle `multiple sep as foo/bar/baz`, but I don't need to conisder it for `owner/repo` or `repo` patterns.
base := strings.TrimPrefix(line, "git@github.com:")
base = strings.TrimPrefix(base, "https://github.com/")
base = strings.TrimSuffix(base, ".git")
// Using Cut cannot handle `multiple sep as foo/bar/baz`, but I don't need to conisder it for `owner/repo` or `repo` patterns.
_, after, found := strings.Cut(base, "/")
if found {
return after
Expand Down
File renamed without changes.
5 changes: 0 additions & 5 deletions pkgs/trim-github-user-prefix-for-reponame/go.mod

This file was deleted.

0 comments on commit a7297f5

Please sign in to comment.