nikivi Posted May 14, 2018 Posted May 14, 2018 (edited) I have this workflow originally made by @vitor and modified by me. It is messy but it works for nearly everything I need it to do. Except one thing. This script tries to run inside it `hub fork`. I have downloaded hub on my system. And I give the full path to hub like so: /usr/local/bin/hub. This fails for me and doesn't actually do the fork. If I run the same command in my terminal however, the command works perfectly well. The debugger shows this when I run it: [2018-05-14 20:31:17][input.scriptfilter] Processing output of 'action.script' with arg '/Users/nikivi/dev/clones/subliminal' [2018-05-14 20:31:17][ERROR: action.script] Error forking repository: Unauthorized (HTTP 401) Requires authentication fatal: Not a git repository (or any of the parent directories): .git fatal: Not a git repository (or any of the parent directories): .git fatal: Not a git repository (or any of the parent directories): .git I suppose it is because Alfred doesn't see my GitHub credentials attached to my Git config but I am not sure how I can solve this, if I can. The purpose of this this object is that after I scan my ~/dev/clones directory and get a list of different repos there, I run an action and it forks the repository using `hub fork` command and then moves the repo from ~/dev/clones to ~/dev/forks. The moving part works, it's the forking that doesn't. Thank you for any help. Edited May 14, 2018 by nikivi
vitor Posted May 14, 2018 Posted May 14, 2018 Do you have a ~/.config/hub? hub also checks for the GITHUB_USER and GITHUB_PASSWORD environment variables, so maybe you have them set in your shell.
nikivi Posted May 14, 2018 Author Posted May 14, 2018 1 hour ago, vitor said: ~/.config/hub I don't have this file. And both of those variables are empty for me. The hub fork works perfectly well when ran from iTerm.
vitor Posted May 14, 2018 Posted May 14, 2018 If you git config --list, which options do you see for hub, if any?
nikivi Posted May 15, 2018 Author Posted May 15, 2018 (edited) The only hub related option I see there is: hub.protocol=https The rest is things from my git config file. Here is an image of it, maybe it is helpful: Edited May 15, 2018 by nikivi
vitor Posted May 15, 2018 Posted May 15, 2018 hub should require one of those things to operate, so everything indicates there’s something in your shell it’s using. Try sourceing your shell’s startup files at the top of the Run Script, and see what happens. nikivi 1
nikivi Posted May 15, 2018 Author Posted May 15, 2018 (edited) Yay. It now forks the repo. However a strange thing happens where the AppleScript that should then cd into the directory I moved to ~/dev/forks doesn't do that. It prints: cd Updating new remote: ~/dev/forks/bat && exanikitavoloboevnikitavoloboev instead of `cd ~/dev/forks/bat && exa. It's strange because I thought that Bash should run things one after another. So it should wait until hub fork finishes doing its thing. And then runs the other stuff like moving the directory, running the two git commands I do: #/usr/local/bin/hub branch --set-upstream-to nikitavoloboev/master master#/usr/local/bin/hub remote rename origin upstream; git remote rename nikitavoloboev origin And then I echo the path of where the fork now should lie with: echo "~/dev/forks/$CLONE_DIR_NAME" The only thing I did change was to add source ~/.zshrc at the top of the Run Script object. Here is the updated workflow. Here is what I get in debugger when I run the action. Should I perhaps put some pauses in the bash script? It already runs slower than I would like it to presumingly because of me sourcing my entire shell env. Edited May 15, 2018 by nikivi
vitor Posted May 15, 2018 Posted May 15, 2018 (edited) Now that it’s confirmed, what you should do is remove the source, figure out what in that file is allowing hub to work, and copy over just that. Or better yet, remove whatever it is until hub breaks in your shell and asks to be configured again, this time into ~/.config/hub. For reference, its config is something like: github.com: - user: username oauth_token: 4c0f1f3023d42e7be5fdb86264aa9cbc02ec5d4b protocol: https Edited May 15, 2018 by vitor nikivi 1
nikivi Posted May 15, 2018 Author Posted May 15, 2018 Never mind all this. I solved it by simply running these `hub` commands in iTerm by creating a zsh function and calling that in iTerm. Zsh function: # Fork cloned repo gfr(){ hub fork git branch --set-upstream-to nikitavoloboev/master master git remote rename origin upstream; git remote rename nikitavoloboev origin } And I just made AppleScript run the commands in succession like so: ❯ cd ~/dev/forks/codehn && gfr && exa Here is the final workflow in the odd chance anyone wants to use it. ? Thank you very much @vitor
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now