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
|
.s2a_login
|
||||||
.work_packages
|
.work_packages
|
||||||
.work_paths
|
.work_paths
|
||||||
.zshklaviyo
|
.zshwork
|
||||||
{{- end }}
|
{{- 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]
|
[user]
|
||||||
name = {{ .name }}
|
name = {{ .name }}
|
||||||
|
{{- if eq .hosttype "work" }}
|
||||||
|
email = {{ .email_work }}
|
||||||
|
{{ else }}
|
||||||
email = {{ .email_personal }}
|
email = {{ .email_personal }}
|
||||||
|
{{- end }}
|
||||||
[core]
|
[core]
|
||||||
editor = hx
|
editor = hx
|
||||||
pager = delta
|
|
||||||
excludesFiles = ~/.config/git/ignore
|
excludesFiles = ~/.config/git/ignore
|
||||||
[interactive]
|
{{ if eq .hosttype "work" }}
|
||||||
diffFilter = delta --color-only
|
sshCommand = "ssh -i ~/.ssh/id_rsa_work"
|
||||||
[delta]
|
{{ end }}
|
||||||
features = chameleon
|
|
||||||
navigate = true
|
|
||||||
light = false
|
|
||||||
side-by-side = true
|
|
||||||
true-color = always
|
|
||||||
colorMoved = default
|
|
||||||
syntax-theme = base16
|
|
||||||
[diff]
|
[diff]
|
||||||
colorMoved = default
|
colorMoved = default
|
||||||
[color]
|
[color]
|
||||||
|
@ -63,8 +57,10 @@
|
||||||
[init]
|
[init]
|
||||||
defaultBranch = main
|
defaultBranch = main
|
||||||
|
|
||||||
[includeIf "gitdir:~/Klaviyo/"]
|
{{- if eq .hosttype "work" }}
|
||||||
path = ~/.gitconfig-work
|
[includeIf "gitdir:~/projects/personal/"]
|
||||||
|
path = ~/.gitconfig-personal-override
|
||||||
|
|
||||||
[includeIf "gitdir:~/.klaviyocli/"]
|
[includeIf "gitdir:~/.local/share/chezmoi"]
|
||||||
path = ~/.gitconfig-work
|
path = ~/.gitconfig-personal-override
|
||||||
|
{{- end }}
|
||||||
|
|
|
@ -50,7 +50,7 @@ srcs=(
|
||||||
"/opt/miniforge3/etc/profile.d/conda.sh"
|
"/opt/miniforge3/etc/profile.d/conda.sh"
|
||||||
"/opt/miniforge3/etc/profile.d/mamba.sh"
|
"/opt/miniforge3/etc/profile.d/mamba.sh"
|
||||||
"$HOME/.cargo/env"
|
"$HOME/.cargo/env"
|
||||||
"$HOME/.zshklaviyo"
|
"$HOME/.zshwork"
|
||||||
"$HOME/.zshprivate"
|
"$HOME/.zshprivate"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,20 @@
|
||||||
[user]
|
[user]
|
||||||
name = {{ .name | quote }}
|
name = {{ .name | quote }}
|
||||||
|
{{- if eq .hosttype "work" }}
|
||||||
|
email = {{ .email_work | quote }}
|
||||||
|
{{ else }}
|
||||||
email = {{ .email_personal | quote }}
|
email = {{ .email_personal | quote }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
[git]
|
[git]
|
||||||
private-commits = "description(glob:'private:*') | bookmarks('merge')"
|
private-commits = "description(glob:'private:*') | bookmarks('merge')"
|
||||||
|
|
||||||
[templates]
|
[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()'
|
git_push_bookmark = '"{{ .github_personal }}_jj_" ++ change_id.short()'
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
[colors]
|
[colors]
|
||||||
"diff removed token" = { fg = "red", underline = false }
|
"diff removed token" = { fg = "red", underline = false }
|
||||||
|
@ -26,9 +34,11 @@ bdiff = ["diff", "-r", "(trunk()..@)::"]
|
||||||
default-command = ["log"]
|
default-command = ["log"]
|
||||||
diff-formatter = ":git"
|
diff-formatter = ":git"
|
||||||
|
|
||||||
|
{{- if eq .hosttype "work" }}
|
||||||
[[--scope]]
|
[[--scope]]
|
||||||
--when.repositories = ["~/Klaviyo", "~/.klaviyocli", "~/projects/work"]
|
--when.repositories = ["~/projects/personal", "~/.local/share/chezmoi"]
|
||||||
[--scope.user]
|
[--scope.user]
|
||||||
email = {{ .email_work | quote }}
|
email = {{ .email_personal | quote }}
|
||||||
[--scope.templates]
|
[--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