Skip to content

Instantly share code, notes, and snippets.

Avatar
😀

Devin Rhode devinrhode2

😀
View GitHub Profile
View I would DIE for a gui.md

I would DIE for a gui

here's the thing

I create lots of well-sequenced, very intentional commits. They are small and repeatable, so it makes it easy to handle rebase conflicts. Just read commit message, see original diff, and 80-90% of the time I believe anyone should be able to see what the original commit was doing and resolve conflict such that same thing is being accomplished on new base. Almost each commit could be one PR, but maybe sometimes it's better to group few commits into one PR.

I'd like to create a PR stack so that it's easy for others to review my changes, but, I don't want to mess around with git branches locally at all. I'm already a surgeon with rebase.

Ideally, I have a gui tool.

@devinrhode2
devinrhode2 / levels.md
Last active Jun 26, 2022
typescript tsconfig compilerOptions settings ranked by value
View levels.md

typescript tsconfig compilerOptions settings ranked by value

@devinrhode2
devinrhode2 / .gitconfig
Last active Jun 23, 2022
git add-archive <sha>
View .gitconfig
[alias]
add-archive = "!runit() { REFS_BRANCH=`git branch -a --contains $1 | xargs` && \
NEW_REF=`echo refs/archive/$(date '+%Y-%m-%d')/$(git config user.name)/$REFS_BRANCH/$(date '+%s')` && \
git update-ref $NEW_REF $1 && \
echo consider deleting $REFS_BRANCH && \
echo attempting to backup archives && \
git push origin refs/archive/*:refs/archive/* && \
echo Here is your remote commit ref url && \
echo https://github.com/TextUsBiz/tesseract/commit/$1; }; runit"
@devinrhode2
devinrhode2 / foo.md
Created May 13, 2022
`brew update` not updating brew taps
View foo.md

I was getting a seemingly unrelated error trying to git fetch upstream main where upstream was a "public" "git-protocol-url" like git://github.com/foo/bar. That's been deprecated and we need to use plain ssh urls... like git@github.com:foo/bar

What I probably didn't need to do, is blow away all my ssh stuff and start from scratch. But I did that, found out I just needed to update the url syntax from git:// to git@github.com:

However, it seems like converting from id_rsa to id_edXXXXX fixed an error with brew update failing to get latest data from my brew taps.

View breakout-small-pr.md

Add to your .gitconfig:

[alias]
  breakout-small-pr = "!runit() { CURRENT_BRANCH=`git branch --show-current`; echo checkout $1 && git checkout $1 && echo delete $2 locally && git branch -D $2 || true && echo create fresh $2 && git checkout -b $2 && echo force publish && git publish-branch --force && echo back to original branch && git checkout $CURRENT_BRANCH; }; runit"

Then:

git break<TAB> 
git breakout-small-pr
@devinrhode2
devinrhode2 / next.config.js
Last active Jul 21, 2022
next.config.js typed with jsdoc, and shared modules. Next 12 + webpack 5. See prior revisions for next 11 support.
View next.config.js
const { safeEnv } = require('./src/env')
// Note: NextConfig type allows any keys, so we are plucking the specific keys we want to type-check.
/**
* @type {Pick<
* import('next').NextConfig,
* | 'webpack'
* | 'env'
* >}
*/
View fail.js
/** @type {(...args: any[]) => never} */
const fail = (...args) => {
console.error(...args)
throw new Error(args.join(''))
}
@devinrhode2
devinrhode2 / idea.md
Last active Jan 24, 2022
post-rewrite git hook - validate every commit?
View idea.md

Something tells me it wouldn't be insurmountable to help facilitate running quality checks on each commit. While it would be nice for git rebase --continue to simply run the normal git hooks when running pick 12498y feature bug fix (i.e. - treat it like an edit plus undo+redo commit. while also maybe preserving date+author information) - OR maybe there's a good argument to add new hooks around rebase-continue.....

What could absolutely be done, I believe without modifications to git core, would be a pre-push hook that basically creates a worktree in the background, steps though each commit, running the quality checks on each commit. However, if a commit has an issue, you'll have to rebase -> edit that commit anyway.

So, here's something I would consider implementing: 1. pre-push check requires clean git status (seems pretty reasonable to me) 2. pre-push hook will somehow automatically rebase whole branch... but run the commit hooks for each commit for you. It's possible some simple checks could be invoked w

View exec.mjs
import { execaCommandSync } from 'execa'
/** @type {(cmdString: string, debug?: 'debug') => [string | undefined, string | unknown]} */
export const exec = (cmdString, debug) => {
let exception
let result
try {
result = execaCommandSync(cmdString, {
env: {
// @ts-expect-error - not application code
@devinrhode2
devinrhode2 / smart-auto-rebase.sh
Last active Dec 16, 2021
this pre-push check just throws you into rebasing :)
View smart-auto-rebase.sh
#!/bin/sh
GIT_ROOT="$(git rev-parse --show-toplevel)"
. "$GIT_ROOT/.husky/common/colors.sh"
REMOTE_NAME="$1"
# REMOTE_URL="$2"
STDIN=$(cat -)
echo "REMOTE_NAME: $REMOTE_NAME"
echo "STDIN: $STDIN"