]>
Dogcows Code - chaz/homebank2ledger/blob - maint/branch_solo.pl
3 # This script prepares the homebank2ledger script for standalone use and puts it in a new branch.
10 use File
::Path
qw(make_path remove_tree);
11 use String
::ShellQuote
;
14 my $version = shift or die 'Need version';
15 my $distdir = shift or die 'Need distdir';
17 my $branch_name = 'solo';
18 my $script_name = 'homebank2ledger';
20 my $branch_oldref = '';
21 my $branch_oldref_origin = '';
23 open(my $fh, '-|', qw{git show-ref}, $branch_name);
24 while (my $line = <$fh>) {
26 my ($hash, $ref) = split(/\s+/, $line);
27 $branch_oldref = $hash if $ref eq "refs/heads/$branch_name";
28 $branch_oldref_origin = $hash if $ref eq "refs/remotes/origin/$branch_name";
30 if ($branch_oldref_origin && $branch_oldref ne $branch_oldref_origin) {
32 system(qw{git branch -f}, $branch_name, "origin/$branch_name");
33 $branch_oldref = $branch_oldref_origin
36 my $commit_msg = shell_quote
("Release $version");
38 my $solodir = "solo_branch.$$";
42 system($Config{'perlpath'}, qw{maint/fatpack.pl}, $distdir);
43 move
($script_name, "$solodir/$script_name");
45 copy
("$distdir/README", "$solodir/README");
47 system(qw{git update-index --add}, glob("$solodir/*"));
48 my $tree_ref = `git write-tree --prefix=$solodir/`;
51 system(qw{git reset});
52 remove_tree
($solodir);
54 my $branch_oldref_safe = shell_quote
($branch_oldref);
55 my $tree_ref_safe = shell_quote
($tree_ref);
56 my $parent = $branch_oldref ? "-p $branch_oldref_safe" : '';
57 my $commit_ref = `git commit-tree -m $commit_msg $parent $tree_ref_safe`;
60 system(qw(git branch -f), $branch_name, $commit_ref);
61 system(qw(git tag -a -m), "Version $version", "$branch_name-$version", $commit_ref);
This page took 0.041816 seconds and 4 git commands to generate.