+
Skip to content

GitSVN: Multi line support of ignore-path, include-paths and skiping of empty commits #834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions perl/Git/SVN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,22 @@ sub find_parent_branch {
return undef;
}

############################################################

=item do_fetch()

Fetch an Commit and returns a log entry

Input: $path - array of strings (Paths) in a commit
$rev - Revision number

Output: $log_entry if successfull
null if skipped
(die) on fetch error

=cut

############################################################
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it is nice that you add documentation, this is a different concern than multi-line support of ignore-path. Those concerns need to be split into separate commits, see https://git-scm.com/docs/git-rebase#_splitting_commits how to do that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Please take a look.
thanks

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you pushed the changed branch yet?

sub do_fetch {
my ($self, $paths, $rev) = @_;
my $ed;
Expand All @@ -1212,6 +1228,11 @@ sub do_fetch {
}
$ed = Git::SVN::Fetcher->new($self);
}
my $skip = $ed->is_empty_commit($paths);
if ($skip){
print "skip commit $rev\n";
return;
}
unless ($self->ra->gs_do_update($last_rev, $rev, $self, $ed)) {
die "SVN connection failed somewhere...\n";
}
Expand Down
42 changes: 37 additions & 5 deletions perl/Git/SVN/Fetcher.pm
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@ sub new {
# override options set in an [svn-remote "..."] section
$repo_id = $git_svn->{repo_id};
my $k = "svn-remote.$repo_id.ignore-paths";
my $v = eval { command_oneline('config', '--get', $k) };
$self->{ignore_regex} = $v;
my @config = eval { command( 'config', '--get-all', $k ) };
chomp(@config); # Replace all \n\r on the end
$self->{ignore_regex} = '(?:'.join('|', @config).')';

$k = "svn-remote.$repo_id.include-paths";
$v = eval { command_oneline('config', '--get', $k) };
$self->{include_regex} = $v;
@config = eval { command( 'config', '--get-all', $k ) };
chomp(@config); # Replace all \n\r on the end
$self->{include_regex} = '(?:'.join('|', @config).')';

$k = "svn-remote.$repo_id.preserve-empty-dirs";
$v = eval { command_oneline('config', '--get', '--bool', $k) };
my $v = eval { command_oneline('config', '--get', '--bool', $k) };
if ($v && $v eq 'true') {
$_preserve_empty_dirs = 1;
$k = "svn-remote.$repo_id.placeholder-filename";
Expand Down Expand Up @@ -137,6 +139,36 @@ sub is_path_ignored {
return 0;
}

############################################################

=item is_empty_commit()

Return 1 if all given $paths are ignored, so that this commit end up in an empty commit

Input: $path - array of strings (Paths) in a commit

Output: { 1 if true, 0 if false }

=cut

############################################################
sub is_empty_commit {
my ( $self, $paths ) = @_;
my $path;
my $ignored;
unless ( defined( $self->{include_regex} ) ) {
return 0;
}

foreach $path ( keys %$paths ) {
$ignored = $self->is_path_ignored($path);
if ( !$ignored ) {
return 0;
}
}
return 1;
}

sub set_path_strip {
my ($self, $path) = @_;
$self->{path_strip} = qr/^\Q$path\E(\/|$)/ if length $path;
Expand Down
2 changes: 2 additions & 0 deletions perl/Git/SVN/Ra.pm
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ sub gs_fetch_loop_common {
my $log_entry = $gs->do_fetch($paths, $r);
if ($log_entry) {
$gs->do_git_commit($log_entry);
}else{
next;
}
$Git::SVN::INDEX_FILES{$gs->{index}} = 1;
}
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载