Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb16259b

Browse files
committed
Remove obsolete pgindent options --code-base and --build
Now that we have the sources for pg_bsd_indent in our code base theseare redundant.It is now required to provide a list of files or directories to pgindent,either by using --commit or on the command line. The equivalent ofpreviously running pgindent with no parameters is now `pgindent .`Some extra checks are also added. duplicate files in the file list areskipped, and there is a warning if no files are specified.If the --commit option is used, the script now chdir's to the sourceroot, as git always reports files relative to that. (Fixes a gripe fromJustin Pryzby)Reviewed by Tom LaneDiscussion:https://postgr.es/m/842819.1676219054@sss.pgh.pa.us
1 parent9a31256 commitb16259b

File tree

2 files changed

+14
-99
lines changed

2 files changed

+14
-99
lines changed

‎src/tools/pgindent/pgindent

Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ my $indent_opts =
2121

2222
my$devnull = File::Spec->devnull;
2323

24-
my ($typedefs_file,$typedef_str,$code_base,
24+
my ($typedefs_file,$typedef_str,
2525
@excludes,$indent,$build,
2626
$show_diff,$silent_diff,$help,
2727
@commits,);
@@ -33,10 +33,8 @@ my %options = (
3333
"commit=s"=> \@commits,
3434
"typedefs=s"=> \$typedefs_file,
3535
"list-of-typedefs=s"=> \$typedef_str,
36-
"code-base=s"=> \$code_base,
3736
"excludes=s"=> \@excludes,
3837
"indent=s"=> \$indent,
39-
"build"=> \$build,
4038
"show-diff"=> \$show_diff,
4139
"silent-diff"=> \$silent_diff,);
4240
GetOptions(%options) || usage("bad command line argument");
@@ -46,22 +44,16 @@ usage() if $help;
4644
usage("Cannot have both --silent-diff and --show-diff")
4745
if$silent_diff &&$show_diff;
4846

49-
usage("Cannot use --commit with--code-base orcommand line file list")
50-
if (@commits &&($code_base ||@ARGV));
47+
usage("Cannot use --commit with command line file list")
48+
if (@commits &&@ARGV);
5149

52-
run_build($code_base)if ($build);
53-
54-
# command line option wins, then environment (which is how --build sets it) ,
55-
# then locations. based on current dir, then default location
50+
# command line option wins, then environment, then locations based on current
51+
# dir, then default location
5652
$typedefs_file ||=$ENV{PGTYPEDEFS};
5753

58-
#build mode sets PGINDENT
54+
#get indent location for environment or default
5955
$indent ||=$ENV{PGINDENT} ||$ENV{INDENT} ||"pg_bsd_indent";
6056

61-
# if no non-option arguments or commits are given, default to looking in the
62-
# current directory
63-
$code_base ||='.'unless (@ARGV ||@commits);
64-
6557
my$sourcedir = locate_sourcedir();
6658

6759
# if it's the base of a postgres tree, we will exclude the files
@@ -121,8 +113,7 @@ sub check_indent
121113
sublocate_sourcedir
122114
{
123115
# try fairly hard to locate the sourcedir
124-
my$where =$code_base ||'.';
125-
my$sub ="$where/src/tools/pgindent";
116+
my$sub ="./src/tools/pgindent";
126117
return$subif-d$sub;
127118
# try to find it from an ancestor directory
128119
$sub ="../src/tools/pgindent";
@@ -320,72 +311,6 @@ sub show_diff
320311
return$diff;
321312
}
322313

323-
subrun_build
324-
{
325-
eval"use LWP::Simple;";## no critic (ProhibitStringyEval);
326-
327-
my$code_base =shift ||'.';
328-
my$save_dir = getcwd();
329-
330-
# look for the code root
331-
foreach (1 .. 5)
332-
{
333-
lastif-d"$code_base/src/tools/pgindent";
334-
$code_base ="$code_base/..";
335-
}
336-
337-
die"cannot locate src/tools/pgindent directory in\"$code_base\"\n"
338-
unless-d"$code_base/src/tools/pgindent";
339-
340-
chdir"$code_base/src/tools/pgindent";
341-
342-
my$typedefs_list_url =
343-
"https://buildfarm.postgresql.org/cgi-bin/typedefs.pl";
344-
345-
my$rv = getstore($typedefs_list_url,"tmp_typedefs.list");
346-
347-
die"cannot fetch typedefs list from$typedefs_list_url\n"
348-
unless is_success($rv);
349-
350-
$ENV{PGTYPEDEFS} = abs_path('tmp_typedefs.list');
351-
352-
my$indentrepo ="https://git.postgresql.org/git/pg_bsd_indent.git";
353-
system("git clone$indentrepo >$devnull 2>&1");
354-
die"could not fetch pg_bsd_indent sources from$indentrepo\n"
355-
unless$? == 0;
356-
357-
chdir"pg_bsd_indent" ||die;
358-
system("make all check >$devnull");
359-
die"could not build pg_bsd_indent from source\n"
360-
unless$? == 0;
361-
362-
$ENV{PGINDENT} = abs_path('pg_bsd_indent');
363-
364-
chdir$save_dir;
365-
return;
366-
}
367-
368-
subbuild_clean
369-
{
370-
my$code_base =shift ||'.';
371-
372-
# look for the code root
373-
foreach (1 .. 5)
374-
{
375-
lastif-d"$code_base/src/tools/pgindent";
376-
$code_base ="$code_base/..";
377-
}
378-
379-
die"cannot locate src/tools/pgindent directory in\"$code_base\"\n"
380-
unless-d"$code_base/src/tools/pgindent";
381-
382-
chdir"$code_base";
383-
384-
system("rm -rf src/tools/pgindent/pg_bsd_indent");
385-
system("rm -f src/tools/pgindent/tmp_typedefs.list");
386-
return;
387-
}
388-
389314
subusage
390315
{
391316
my$message =shift;
@@ -397,10 +322,8 @@ Options:
397322
--commit=gitref use files modified by the named commit
398323
--typedefs=FILE file containing a list of typedefs
399324
--list-of-typedefs=STR string containing typedefs, space separated
400-
--code-base=DIR path to the base of PostgreSQL source code
401325
--excludes=PATH file containing list of filename patterns to ignore
402326
--indent=PATH path to pg_bsd_indent program
403-
--build build the pg_bsd_indent program
404327
--show-diff show the changes that would be made
405328
--silent-diff exit with status 2 if any changes would be made
406329
The --excludes and --commit options can be given more than once.
@@ -423,8 +346,6 @@ $filtered_typedefs_fh = load_typedefs();
423346

424347
check_indent();
425348

426-
build_clean($code_base)if$build;
427-
428349
my$wanted =sub
429350
{
430351
my ($dev,$ino,$mode,$nlink,$uid,$gid);
@@ -434,12 +355,12 @@ my $wanted = sub
434355
&&push(@files,$File::Find::name);
435356
};
436357

437-
# get the list of files under code base, if it's set
438-
File::Find::find({wanted=>$wanted },$code_base)if$code_base;
439-
440358
# any non-option arguments are files or directories to be processed
441359
File::Find::find({wanted=>$wanted},@ARGV)if@ARGV;
442360

361+
# commit file locations are relative to the source root
362+
chdir"$sourcedir/../../.."if@commits &&$sourcedir;
363+
443364
# process named commits by comparing each with their immediate ancestor
444365
foreachmy$commit (@commits)
445366
{
@@ -450,6 +371,8 @@ foreach my $commit (@commits)
450371
push(@files,@affected);
451372
}
452373

374+
warn"No files to process"unless@files;
375+
453376
# remove excluded files from the file list
454377
process_exclude();
455378

‎src/tools/pgindent/pgindent.man

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ You can see all the options by running:
88
pgindent --help
99

1010
In its simplest form, if all the required objects are installed, simply run
11-
itwithout any parametersat the top of the source tree you want to process.
11+
it at the top of the source tree you want to process like this:
1212

13-
pgindent
14-
15-
If you don't have all the requirements installed, pgindent will fetch and build
16-
them for you, if you're in a PostgreSQL source tree:
17-
18-
pgindent --build
13+
pgindent .
1914

2015
If your pg_bsd_indent program is not installed in your path, you can specify
2116
it by setting the environment variable INDENT, or PGINDENT, or by giving the
@@ -28,9 +23,6 @@ specified using the PGTYPEDEFS environment variable, or via the command line
2823
--typedefs option. If neither is used, it will look for it within the
2924
current source tree, or in /usr/local/etc/typedefs.list.
3025

31-
If you want to indent a source tree other than the current working directory,
32-
you can specify it via the --code-base command line option.
33-
3426
We don't want to indent certain files in the PostgreSQL source. pgindent
3527
will honor a file containing a list of patterns of files to avoid. This
3628
file can be specified using the --excludes command line option. If indenting

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp