Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Fix an issue in the GitDirectory loop when trying to commit without any actual changes #369

Merged
merged 1 commit into from
Aug 30, 2019

Conversation

silenceshell
Copy link
Contributor

I have met an error when using gitops. Here are the steps to reproduce the error.

  1. create a github repo and use ignited to watch the repo
  2. add a yaml file like gitops sample code to git repo
  3. ignited creates a new vm, and update the yaml and commit&push to git
  4. in the git repo dir, update the yaml, change the diskSize to 4GB, and git add&commit&push to master branch
  5. ignited do updated the vm, but it exits.

here is the log when ignited exits:

INFO[0214] New commit observed on branch "master": 32979b36abdbadd445fd949f4442728ef8eed5a0. User initiated: true
FATA[0215] The GitOps commit loop terminated with an error git commit and/or push error: no changes made in repo

There is nothing to commit, but ignited still try to commit and push, and caused the error.

I think the code below maybe is the spot:

func (d *GitDirectory) commitLoop() error {
...
		files, err := d.checkout.ChangedFiles(context.Background(), d. branch)

It equals to git diff --name-only --diff-filter=ACMRT master --. In the tmp dir like /tmp/flux-working259394949, this command always output git-vm.yaml, no matter I update the yaml file or not.

Is it better to use d.lastCommit as ref? It do fix my problem.

@luxas luxas added this to the v0.6.0 milestone Aug 30, 2019
@luxas luxas self-assigned this Aug 30, 2019
@luxas luxas added kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Aug 30, 2019
Copy link
Contributor

@luxas luxas left a comment

Choose a reason for hiding this comment

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

Thanks very much for this change!
Very appreciated

LGTM 👍

@luxas luxas merged commit 0ec02c0 into weaveworks:master Aug 30, 2019
luxas added a commit to weaveworks/libgitops that referenced this pull request Aug 30, 2019
@luxas luxas changed the title fix unnecessary commit Fix an issue in the GitDirectory loop when trying to commit without any actual changes Aug 30, 2019
@silenceshell silenceshell deleted the fix-unnessary-commit branch August 31, 2019 02:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants