2 * This file is part of the vng project
3 * Copyright (C) 2008 Thomas Zander <tzander@trolltech.com>
4 * Copyright (C) 2002-2004 David Roundy
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "CommandLineParser.h"
21 #include "GitRunner.h"
22 #include "commits/Commit.h"
28 static const CommandLineOption options
[] = {
29 // {"-a, --all", "answer yes to all patches"},
30 // {"--to-match=PATTERN", "select changes up to a patch matching PATTERN"},
31 // {"--to-patch=REGEXP", "select changes up to a patch matching REGEXP"},
32 // {"--to-tag=REGEXP", "select changes up to a tag matching REGEXP"},
33 // {"--from-match=PATTERN", "select changes starting with a patch matching PATTERN"},
34 // {"--from-patch=REGEXP", "select changes starting with a patch matching REGEXP"},
35 // {"--from-tag=REGEXP", "select changes starting with a tag matching REGEXP"},
36 {"--last NUMBER", "select the last NUMBER patches"},
37 // {"--matches=PATTERN", "select patches matching PATTERN"},
38 // {"-p, --patches=REGEXP", "select patches matching REGEXP"},
39 // {"-t, --tags=REGEXP", "select tags matching REGEXP"},
40 // {"--context", "give output suitable for get --context"},
41 // {"--xml-output", "generate XML formatted output"},
42 // {"--human-readable", "give human-readable output"},
43 // {"-s, --summary", "summarize changes"},
44 // {"--no-summary", "don't summarize changes"},
45 // {"--reverse", "show changes in reverse order"},
50 : AbstractCommand("changes")
52 CommandLineParser::addOptionDefinitions(options
);
55 QString
Changes::argumentDescription() const
57 return "[FILE or DIRECTORY]";
60 QString
Changes::commandDescription() const
62 return "Gives a changelog-style summary of the repository history.\n";
65 AbstractCommand::ReturnCodes
Changes::run()
67 if (! checkInRepository())
69 CommandLineParser
*args
= CommandLineParser::instance();
72 QStringList arguments
;
73 arguments
<< "whatchanged" << "-m" << "--pretty=raw";
75 if (args
->contains("last"))
76 arguments
<< "-n" << args
->optionArgument("last");
78 GitRunner
runner(git
, arguments
);
79 ReturnCodes rc
= runner
.start(GitRunner::WaitForStandardOutput
);
81 // TODO proper reporting
87 Commit commit
= Commit::createFromStream(&git
);
88 if (! commit
.isValid())
90 Logger::info() << commit
.commitTime().toString() << " " << commit
.author() << endl
;
91 Logger::info() << commit
.logMessage();
95 git
.waitForFinished();