Skip to content

Commit

Permalink
add dfm subcommand 'updates'
Browse files Browse the repository at this point in the history
  • Loading branch information
justone committed Sep 5, 2010
1 parent ea1dc7b commit bbceca6
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions bin/dfm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ my %opts;
if ( $command eq 'install' ) {
GetOptions( \%opts, 'verbose', 'quiet', 'dry-run', 'help' );

if ($opts{'help'}) {
if ( $opts{'help'} ) {
show_usage();
exit;
}
Expand All @@ -50,6 +50,31 @@ if ( $command eq 'install' ) {
# link in the bash loader
configure_bash_loader();
}
elsif ( $command eq 'updates' ) {
GetOptions( \%opts, 'verbose', 'quiet', 'dry-run', 'no-fetch', 'help' );

if ( $opts{'help'} ) {
show_usage();
exit;
}

chdir( $ENV{HOME} . '/' . $repo_dir );

if ( !$opts{'no-fetch'} ) {
DEBUG('fetching changes');
system("git fetch") if !$opts{'dry-run'};
}

my $current_branch = `git symbolic-ref HEAD`;
chomp $current_branch;

# convert 'refs/heads/personal' to 'personal'
$current_branch =~ s/^.+\///g;

DEBUG("current branch: $current_branch");

system("git log --pretty='format:%h: %s' $current_branch..origin/$current_branch");
}
else {

# assume it's a git command and call accordingly
Expand Down Expand Up @@ -155,6 +180,7 @@ sub show_usage {
print <<END;
Usage:
dfm install [--verbose|--quiet] [--dry-run]
dfm updates [--verbose|--quiet] [--dry-run] [--no-fetch]
dfm [git subcommand] [git options]
For full documentation, run "perldoc ~/$repo_dir/bin/dfm".
Expand All @@ -171,13 +197,23 @@ __END__
dfm install [--verbose|--quiet] [--dry-run]
dfm updates [--verbose|--quiet] [--dry-run] [--no-fetch]
dfm [git subcommand] [git options]
=head1 DESCRIPTION
Manages installing files from and operating on a repository that contains
dotfiles.
=head1 COMMON OPTIONS
All the subcommands implemented by dfm have the following options:
--verbose Show extra information about what dfm is doing
--quiet Show as little info as possible.
--dry-run Don't do anything.
=head1 COMMANDS
=over
Expand All @@ -188,7 +224,13 @@ This installs everything in the repository into the current user's home
directory by making symlinks. To skip any files, add their names to a file
named 'skip' in the base of the repository. This is the default command.
=item dfm [git subcommand]
=item dfm updates [--no-fetch]
This fetches any changes from the origin remote and then shows a shortlog of
what updates would come in if merged into the current branch. Use '--no-fetch'
to skip the fetch and just show what's new.
=item dfm [git subcommand] [git options]
This runs any git command as if it was inside the dotfiles repository. For
instance, this makes it easy to commit changes that are made by running 'dfm
Expand Down

0 comments on commit bbceca6

Please sign in to comment.