Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[vault] Commit unit even if no changes. Fixes MER#1307
Signed-off-by: Denis Zalevskiy <denis.zalevskiy@jolla.com>
  • Loading branch information
Denis Zalevskiy committed Sep 11, 2015
1 parent 786c693 commit 68be98e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/vault.cpp
Expand Up @@ -646,6 +646,17 @@ bool Vault::setState(const QString &state)
return writeFile(fileName(File::State), state);
}

// TODO move to the library
Gittin::Commit commitEvenIfClean(Gittin::Repo &vcs, QString const &msg)
{
auto options = QStringList() << "--allow-empty" << "-m" << msg;
vcs.command("commit", options);
auto log_opts = QStringList() << "-n1" << "--oneline" << "--no-abbrev-commit";
auto commit = vcs.command("log", log_opts)->stdout();
// TODO: FIX: object takes unsafe pointer to another object
return Gittin::Commit(&vcs, commit.split(' ').first());
}

struct Unit
{
Unit(const QString &unit, const QString &home, Gittin::Repo *vcs, const config::Unit &config)
Expand Down Expand Up @@ -761,8 +772,7 @@ struct Unit
error::raise({{"msg", "Dirty tree"}, {"dir", m_root.path()}/*, {"status", status_dump(status)}*/});
}
}

m_vcs->commit(">" + name);
commitEvenIfClean(*m_vcs, Snapshot(m_vcs, name).tag().name());
status = m_vcs->status(m_root.path());
if (!status.isClean()) {
error::raise({{"msg", "Not fully commited"}, {"dir", m_root.path()}/*, {"status", status_dump(status)}*/});
Expand Down
10 changes: 5 additions & 5 deletions tools/git-vault-rebase-generate.awk
Expand Up @@ -32,9 +32,9 @@ function prepare_commands() {
split(commits[name], ids, SUBSEP);
push_step("data:" name);
if (length(ids) == 1) {
push_command("git cherry-pick " ids[1]);
push_command("git cherry-pick --allow-empty " ids[1]);
} else {
cmd="git cherry-pick " ids[1];
cmd="git cherry-pick --allow-empty " ids[1];
for (i = 1; i <= length(ids); i++) {
cmd = cmd " && git cherry-pick --no-commit " ids[i] \
" && git commit --no-edit --amend --allow-empty";
Expand All @@ -57,7 +57,7 @@ function prepare_commands() {
push_command("git commit --no-edit --amend --allow-empty");
} else {
push_step("tag:" tag);
push_command("git cherry-pick " id);
push_command("git cherry-pick --allow-empty " id);
}
tmp_tag = "migrate/" tag
push_command(sprintf("git tag -f '%s'", tmp_tag));
Expand All @@ -77,7 +77,7 @@ $1 == "add" {
$1 == "old_tag" {
push_step("old_tag:" $3);
if (length(old_tags) == 0) {
push(old_tags, length(old_tags), "git cherry-pick " $2);
push(old_tags, length(old_tags), "git cherry-pick --allow-empty " $2);
} else {
push(old_tags, length(old_tags), "git cherry-pick --no-commit " $2);
push(old_tags, length(old_tags), "git commit --no-edit --amend --allow-empty");
Expand All @@ -90,7 +90,7 @@ $1 == "tag" {

$1 == "copy" {
push_step("copy:" $2);
push_command("git cherry-pick " $2);
push_command("git cherry-pick --allow-empty " $2);
}

$1 == "start" {
Expand Down

0 comments on commit 68be98e

Please sign in to comment.