14 pname = "darcs-to-git";
15 version = "0-unstable-2024-09-30";
17 src = fetchFromGitHub {
19 repo = "darcs-to-git";
20 rev = "9d556cb7daa06b9de3cb97487b98bab2869a7fe7";
21 hash = "sha256-0GKSzqgJgi1w4uZOqixp/F6i7hK2ZmuQI0px8FEDFXM=";
26 matchExecution = ''(\<(output_of|system|run)\([^"%]*("|%w\()|^[^"`]*`)'';
30 -e '1s|^#!.*|#!${ruby}/bin/ruby|' \
31 -e 's!${matchExecution}git\>!\1${git}/bin/git!' \
32 -e 's!${matchExecution}darcs\>!\1${darcs}/bin/darcs!' \
33 -e 's!${matchExecution}diff\>!\1${diffutils}/bin/diff!' \
34 -e 's!\<egrep\>!${gnugrep}/bin/egrep!g' \
35 -e 's!%w\(darcs init\)!%w(${darcs}/bin/darcs init)!' \
40 install -vD darcs-to-git "$out/bin/darcs-to-git"
43 passthru.updateScript = unstableGitUpdater { };
49 darcs_repos="$(pwd)/darcs_test_repos"
50 git_repos="$(pwd)/git_test_repos"
51 test_home="$(pwd)/test_home"
52 mkdir "$darcs_repos" "$git_repos" "$test_home"
54 ${darcs}/bin/darcs init
55 echo "this is a test file" > new_file1
56 ${darcs}/bin/darcs add new_file1
57 HOME="$test_home" ${darcs}/bin/darcs record -a -m c1 -A none
58 echo "testfile1" > new_file1
59 echo "testfile2" > new_file2
60 ${darcs}/bin/darcs add new_file2
61 HOME="$test_home" ${darcs}/bin/darcs record -a -m c2 -A none
62 ${darcs}/bin/darcs mv new_file2 only_one_file
64 HOME="$test_home" ${darcs}/bin/darcs record -a -m c3 -A none
66 HOME="$test_home" PATH= "$orig_dir/darcs-to-git" "$darcs_repos"
67 assertFileContents() {
68 echo -n "File $1 contains '$2'..." >&2
69 if [ "x$(cat "$1")" = "x$2" ]; then
73 echo " failed: '$(cat "$1")' != '$2'" >&2
77 echo "Checking if converted repository matches original repository:" >&2
78 assertFileContents only_one_file testfile2
79 ${git}/bin/git reset --hard HEAD^
80 assertFileContents new_file1 testfile1
81 assertFileContents new_file2 testfile2
82 ${git}/bin/git reset --hard HEAD^
83 assertFileContents new_file1 "this is a test file"
84 echo "All checks passed." >&2
86 rm -rf "$darcs_repos" "$git_repos" "$test_home"
90 description = "Converts a Darcs repository into a Git repository";
91 homepage = "http://www.sanityinc.com/articles/converting-darcs-repositories-to-git";
92 license = lib.licenses.mit;
93 platforms = lib.platforms.unix;
94 mainProgram = "darcs-to-git";