refactor work handling
This commit is contained in:
parent
7f09b9fab4
commit
4a65f1304f
8 changed files with 30 additions and 98 deletions
|
@ -6,5 +6,5 @@
|
|||
.s2a_login
|
||||
.work_packages
|
||||
.work_paths
|
||||
.zshklaviyo
|
||||
.zshwork
|
||||
{{- end }}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
|
||||
echo "usage: $0 <repo_name> <branch_name>"
|
||||
echo "example: $0 k-repo foo-branch1"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||
echo "error: invalid number of arguments"
|
||||
echo "usage: $0 <repo_name> <branch_name>"
|
||||
echo "run with --help for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
REPO_NAME="$1"
|
||||
BRANCH_NAME="$2"
|
||||
|
||||
REPO_PATH="$HOME/Klaviyo/Repos/$REPO_NAME"
|
||||
|
||||
if [ ! -d "$REPO_PATH" ]; then
|
||||
echo "error: repository directory does not exist: $REPO_PATH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd "$REPO_PATH" || exit 1
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
echo "no branch name provided. listing github prs..."
|
||||
|
||||
PR_LIST=$(gh pr list --limit 300 --json number,title,headRefName \
|
||||
--template '{{range .}}{{.number}} | {{.title}} |{{.headRefName}}{{"\n"}}{{end}}')
|
||||
|
||||
if [ -z "$PR_LIST" ]; then
|
||||
echo "error: failed to fetch pr list from github"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SELECTED_PR=$(echo "$PR_LIST" | fzf --delimiter='|' --with-nth=1,2 --prompt='pick a github pr > ' | awk -F'|' '{print $3}')
|
||||
|
||||
if [ -z "$SELECTED_PR" ]; then
|
||||
echo "no pr selected"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BRANCH_NAME="$SELECTED_PR"
|
||||
fi
|
||||
|
||||
# Escape branch name for filesystem use
|
||||
SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/\//_/g' | sed 's/+/-/g')
|
||||
|
||||
PR_NUMBER=""
|
||||
if [ -n "$BRANCH_NAME" ]; then
|
||||
PR_NUMBER=$(echo "$PR_LIST" | grep "|.*$BRANCH_NAME$" | awk -F'|' '{print $1}' | head -1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
|
||||
fi
|
||||
|
||||
jj git fetch || exit 1
|
||||
PARENT_DIR="$HOME/projects/work/reviews/$REPO_NAME"
|
||||
mkdir -p "$PARENT_DIR" || exit 1
|
||||
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
WORKSPACE_DIR="$PARENT_DIR/${PR_NUMBER}_${SAFE_BRANCH_NAME}"
|
||||
else
|
||||
WORKSPACE_DIR="$PARENT_DIR/$SAFE_BRANCH_NAME"
|
||||
fi
|
||||
|
||||
jj workspace add "$WORKSPACE_DIR" -r "$BRANCH_NAME@origin" || exit 1
|
||||
echo "successfully created workspace for $REPO_NAME/$BRANCH_NAME"
|
||||
|
||||
prr get "klaviyo/$REPO_NAME/$PR_NUMBER"
|
||||
echo "cd $WORKSPACE_DIR && prr edit klaviyo/$REPO_NAME/$PR_NUMBER"
|
2
home/dot_gitconfig-personal-override.tmpl
Normal file
2
home/dot_gitconfig-personal-override.tmpl
Normal file
|
@ -0,0 +1,2 @@
|
|||
[user]
|
||||
email = {{ .email_personal }}
|
|
@ -1,5 +0,0 @@
|
|||
[user]
|
||||
email = {{ .email_work }}
|
||||
|
||||
[core]
|
||||
sshCommand = "ssh -i ~/.ssh/id_rsa_work"
|
|
@ -1,22 +1,16 @@
|
|||
[include]
|
||||
path = /opt/local/share/git-delta/themes.gitconfig
|
||||
[user]
|
||||
name = {{ .name }}
|
||||
{{- if eq .hosttype "work" }}
|
||||
email = {{ .email_work }}
|
||||
{{ else }}
|
||||
email = {{ .email_personal }}
|
||||
{{- end }}
|
||||
[core]
|
||||
editor = hx
|
||||
pager = delta
|
||||
excludesFiles = ~/.config/git/ignore
|
||||
[interactive]
|
||||
diffFilter = delta --color-only
|
||||
[delta]
|
||||
features = chameleon
|
||||
navigate = true
|
||||
light = false
|
||||
side-by-side = true
|
||||
true-color = always
|
||||
colorMoved = default
|
||||
syntax-theme = base16
|
||||
{{ if eq .hosttype "work" }}
|
||||
sshCommand = "ssh -i ~/.ssh/id_rsa_work"
|
||||
{{ end }}
|
||||
[diff]
|
||||
colorMoved = default
|
||||
[color]
|
||||
|
@ -63,8 +57,10 @@
|
|||
[init]
|
||||
defaultBranch = main
|
||||
|
||||
[includeIf "gitdir:~/Klaviyo/"]
|
||||
path = ~/.gitconfig-work
|
||||
{{- if eq .hosttype "work" }}
|
||||
[includeIf "gitdir:~/projects/personal/"]
|
||||
path = ~/.gitconfig-personal-override
|
||||
|
||||
[includeIf "gitdir:~/.klaviyocli/"]
|
||||
path = ~/.gitconfig-work
|
||||
[includeIf "gitdir:~/.local/share/chezmoi"]
|
||||
path = ~/.gitconfig-personal-override
|
||||
{{- end }}
|
||||
|
|
|
@ -50,7 +50,7 @@ srcs=(
|
|||
"/opt/miniforge3/etc/profile.d/conda.sh"
|
||||
"/opt/miniforge3/etc/profile.d/mamba.sh"
|
||||
"$HOME/.cargo/env"
|
||||
"$HOME/.zshklaviyo"
|
||||
"$HOME/.zshwork"
|
||||
"$HOME/.zshprivate"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
[user]
|
||||
name = {{ .name | quote }}
|
||||
{{- if eq .hosttype "work" }}
|
||||
email = {{ .email_work | quote }}
|
||||
{{ else }}
|
||||
email = {{ .email_personal | quote }}
|
||||
{{- end }}
|
||||
|
||||
[git]
|
||||
private-commits = "description(glob:'private:*') | bookmarks('merge')"
|
||||
|
||||
[templates]
|
||||
{{- if eq .hosttype "work" }}
|
||||
git_push_bookmark = '"2025_{{ .github_work }}_jj_" ++ change_id.short()'
|
||||
{{ else }}
|
||||
git_push_bookmark = '"{{ .github_personal }}_jj_" ++ change_id.short()'
|
||||
{{- end }}
|
||||
|
||||
[colors]
|
||||
"diff removed token" = { fg = "red", underline = false }
|
||||
|
@ -26,9 +34,11 @@ bdiff = ["diff", "-r", "(trunk()..@)::"]
|
|||
default-command = ["log"]
|
||||
diff-formatter = ":git"
|
||||
|
||||
{{- if eq .hosttype "work" }}
|
||||
[[--scope]]
|
||||
--when.repositories = ["~/Klaviyo", "~/.klaviyocli", "~/projects/work"]
|
||||
--when.repositories = ["~/projects/personal", "~/.local/share/chezmoi"]
|
||||
[--scope.user]
|
||||
email = {{ .email_work | quote }}
|
||||
email = {{ .email_personal | quote }}
|
||||
[--scope.templates]
|
||||
git_push_bookmark = '"2025_{{ .github_work }}_jj_" ++ change_id.short()'
|
||||
git_push_bookmark = '"{{ .github_personal }}_jj_" ++ change_id.short()'
|
||||
{{- end }}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue