Use current branch name in gitShowReason(), not just master

This commit is contained in:
Gerhard Hoffmann 2023-10-09 15:53:35 +02:00
parent edeff35d7e
commit 355b28ba40
2 changed files with 4 additions and 6 deletions

View File

@ -114,16 +114,14 @@ bool GitClient::gitCloneAndCheckoutBranch() {
return false;
}
QStringList GitClient::gitShowReason() {
QStringList GitClient::gitShowReason(QString branchName) {
QStringList lst;
if (QDir(m_customerRepository).exists()) {
// %h: commit (short form)
// %s: commit message
// %cI: commit date, strict ISO 8601 format
// Note: use master branch. By convention, there is a ChangeLog file
// in the root of the repository, which has to be always the last file
// to be checked in when the customer repository somehow changed.
Command c("git show origin/master -s --format=\"c=%h m=%s d=%cI\"");
// Note: branch with branchName has to exist: format zg1/zone1
Command c(QString("git show origin/%1 -s --format=\"c=%h m=%s d=%cI\"").arg(branchName));
if (c.execute(m_customerRepository)) {
QString const s = c.getCommandResult().trimmed();
int const c = s.indexOf("c=");

View File

@ -50,7 +50,7 @@ class GitClient : public QObject {
std::optional<QStringList> gitMerge();
QString gitLastCommit(QString fileName);
QStringList gitShowReason();
QStringList gitShowReason(QString branchName);
static QString gitBlob(QString fileName);
QString gitCommitForBlob(QString blob);
bool gitIsFileTracked(QString file2name);