I have a few different darcs repos and I would like to write a script to automatically push changes from these repos at the end of the day. I read at this thread that the "right" way to script darcs is using the library. But here http://darcs.net/Library it says that "it is very much a work in progress" and lacks a stable API. What is the "right" way to script darcs.
It's perfectly fine to script everyday darcs commands, like any other command-line program. It's also fine to script interactive darcs commands, but that's where it gets fragile, because those interactive prompts get refined and changed quite often in new darcs releases. So if at all possible, make the command non-interactive, eg using the -a/--all flag. Push and pull is easy, here's a regular pull that I run from /etc/crontab:
*/15 * * * * darcsden cd /home/darcsden/darcs/darcs-reviewed; darcs pull -a http://darcs.net/reviewed >/dev/null # 2>&1
but watch out for things that can prevent a successful non-interactive push or pull:
conflicts, especially with unrecorded changes
wrong user/file ownership/file permissions
stray _darcs/lock file left over from an abnormal termination
Related
I working on Git now and having a big problem.
The command git bisect run needs to be like that:
$ git bisect run <my_script> $arguments
But I need to work with git bisect run only in one script.
I know that my solution with 2 scripts works but I can't find a way to combine them.
What can I do that will resolve the problem?
I tried to use:
git bisect run sh -c
As example: In working on git and writing: bash ../bisecter.sh 102. When bisecter.sh is the name of the script and 102 is something we need to search in the commits. And this script I'm trying to write. With bisect and bash commands.
You could check to see if the program is being run in "interactive mode" and run the appropriate command. If it's interactive, run git bisect. If it isn't, you're being run by git bisect.
An interactive shell is one started without non-option arguments (unless -s is
specified) and without the -c option whose standard input and error are both con-
nected to terminals (as determined by isatty(3)), or one started with the -i
option. PS1 is set and $- includes i if bash is interactive, allowing a shell
script or a startup file to test this state.
In bash you can check if file descriptor 1 (stdout) is outputting to a terminal.
if [ -t 1 ]; then
echo "We're run from a shell, run git-bisect"
else
echo "We're not run from a shell, do the bisecting."
fi
$ ./test.sh
We're run from a shell, run git-bisect
$ ./test.sh | cat
We're not run from a shell, do the bisecting.
But I seriously doubt that's what your professor intends you to do. The requirement to pass the same program to git bisect as runs git bisect doesn't make sense. Either the professor has an odd requirement, a distinct possibility, or perhaps you've misunderstood how to solve the problem.
When bisecter.sh is the name of the script and 102 is something we need to search in the commits.
git bisect is not for searching like that. It is for finding which commit caused a bug.
If you want to find which commit made a particular change, either in the log messages or in the changes, use git log -S or git log -G. That makes sense to do it in a single file.
I often find myself appending --help|less to commands that I am crafting a command in a shell to explore the CLI of the program I am using. What ways are there to accomplish the same thing with fewer key-presses?
For instance, if I wanted to use the new way of switching branches (I don't, I'm stuck in my ways happily doing git checkout -b other_branch) then my history (and thought process) could look like
git change other_branch # Guess what the command should be
git --help|less # Backtrack to where I am confident I know the command and ask for help
git switch --help|less # Gradually build up the command from there
git switch other_branch
For context:
I typically want the pager either to be able to search or because I am working in tmux and activating scrolling takes a few additional, and awkward, key-presses.
I typically use zsh on Ubuntu or Debian.
I typically use arrow up to iterate on my previous command.
Add the following to your .zshrc file:
# Alt-H: Open `man` page of current command.
unalias run-help
autoload -Uz run-help{,-{git,ip,openssl,p4,sudo,svk,svn}}
Then restart your shell.
Now, whenever you're in the middle of typing a command, you can press AltH (^[h) to immediately open the man page for that command. Then, after you quit your pager, Zsh will will automatically restore your command line, so you can finish typing.
I'm using cygwin under Windows to do some command line stuff. One of the commands I use sometimes is git stash. Since few weeks I always get this error when I use it: Cannot save the current index state
I also tried it in other projects, so it is no project related issue. The history is not broken or something like that. I don't use it often so I don't know when the issue started.
The error is thrown on line 110 of the git-stash file. That's why I debugged the two lines before.
$(printf 'index on %s\n' "$msg" |
git commit-tree $i_tree -p $b_commit)
When I echo the first command it outputs my last commit. This seems ok. When I output both commands piped it is empty, so maybe something is wrong with "git commit-tree $i_tree -p $b_commit". I google a long time but was not able to find a solution to this issue.
Cygwin Git version: 2.14.1
Cygwin x64 version: 2.8.2(0.313/5/3)
First, check if the issue persists with bash (the bash packaged with Git). Make sure to set your PATH in order to:
no include cygwin
include git/bin, git/usr/bin, git/mingw64/bin: see this example.
Working with a simplified path (for testing purposes) is important to make sure there is no side-effect from any other software.
Second, try and add a git status in the git stash critical lines, to see if the Git repo status reveal anything suspicious.
This is my script to automate the git push of my static blog.
When I run each command one by one in the Terminal, it works. Do I need to add delays, maybe it's going too fast. The pelican command (static website generator) takes quite a lot of time (2 seconds). Is the rest of the script crashing during that?
#!/bin/sh
dropbox
cd blog
pelican . -s /Users/Paul-Arthur/Desktop/Desktop/Dropbox/blog/pelican.conf.py -t subtle
cd output
git add .
git commit -m 'commit'
git push
Updated: Sorry, yeah dropbox is a custom command in my bash_profile (this is not the problem, it works I know ;) ).
Sadly, when I click my script, it executes (but does not work) extremely quickly so I cannot see the errors.
Here is the output from the calepin command. The errors are normal and I expect it to run with that. Do you think that this is the problem? If so what can I do?
familys-imac:blog Paul-Arthur$ pelican . -s /Users/Paul-Arthur/Desktop/Desktop/Dropbox/blog/pelican.conf.py -t subtle
ERROR: Skipping ./articles/aboutme.md: impossible to find informations about 'title'
ERROR: Skipping ./articles/static_sites.md: impossible to find informations about 'title'
familys-imac:blog Paul
It might be due to the « cd » command, since it's not a command, it is a builtin from the shell, and doesn't act like a command.
To debug it, try adding «pwd» command inside your script before and after the «cd» line, to be sure the working directory has change.
It could also be due to the shell you are using, in the shebang (first line of your script), you are using the /bin/sh script. Is it the good one ? When you do it in your shell, you are maybe using another like bash, dash, zsh etc.
To determine that, type that in your current shell :
which `echo $0`
You will get an answer like :
/bin/bash
or something like this. Use this in your shell script :
#!/bin/bash
And try again your script.
Good luck with your project.
I'm trying to get a git commit email hook running using Git on Windows. I'm sure I've got my copy of contrib/hooks/post-receive-email (placed in the project's .git/hooks/post-commit) script messed up, or I'm missing an important node in my config, but I don't know where I would see any error messages.
Would they be echoed to stdout when I commit using a shell? Is there some flag I would need to set or pass to git commit to see them (I tried -v with no apparent effect)?
EDIT
Here are the repo-specific config vals I've added:
sendemail.smtpserver=smtp.mycompany.com
hooks.mailinglist=me#domain.com
UPDATE
The overall problem is that git's built-in mail doesn't work on windows (which makes perfect sense, of course), but at least now I know where to look for output from my hacking attempts.
Are you sure the hook is actually being executed? (Make sure it's executable!) The post-commit hook is run in the same way as git-commit, so if you commit from a shell, you should see the output of all the commit-related hooks along with the output of git-commit itself in that terminal.