saltstack / saltstack/salt

Module function git.commit threw an exception when there is nothing to commit

Open
#38,552 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Execution-Module P4 RIoT severity-medium stale
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description of Issue/Question

If there is nothing to commit in the path to the git checkout, I get the following exception error when applying the state.

----------
          ID: git-commit
    Function: module.run
        Name: git.commit
      Result: False
     Comment: Module function git.commit threw an exception. Exception: Command 'git commit -m commited by SaltStack' failed
     Started: 10:24:52.712617
    Duration: 10.998 ms
     Changes:
----------

whereas if I run the "git commit -m message" command directly on the minion in the path to the git checkout, it would not fail and just returns:

On branch master
nothing to commit, working directory clean
Setup

contents of SLS file:

init-git:
  module.run:
    - name: git.init
    - cwd: /path/to/repo/
    - unless: ls /path/to/repo/.git

git-set-url:
  module.run:
    - name: git.remote_set
    - cwd: /path/to/repo/
    - remote: origin
    - url: #url to the git repository
    - https_user: username
    - https_pass: {{ pillar['password'] }}
    - onchanges:
      - module: init-git

git-fetch:
  module.run:
    - name: git.fetch
    - cwd: /path/to/repo/
    - remote: origin

git-pull:
  module.run:
    - name: git.pull
    - cwd: /path/to/repo/
    - opts: 'origin master'

git-add:
  module.run:
    - name: git.add
    - cwd: /path/to/repo/
    - filename: /path/to/repo/
    - remote: origin
    - opts: '-A'

git-commit:
  module.run:
    - name: git.commit
    - cwd: /path/to/repo/
    - message: "committed by SaltStack"
    - ignore_retcode: True

git-push:
  module.run:
    - name: git.push
    - cwd: /path/to/repo/
    - remote: origin
    - ref: master
    - branch: master

Steps to Reproduce Issue
  1. have a repository to commit to it
  2. run the SLS against a minion
Versions Report
Salt Version:
           Salt: 2016.3.2

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
         pygit2: Not Installed
         Python: 2.7.6 (default, Oct 26 2016, 20:30:19)
   python-gnupg: Not Installed
         PyYAML: 3.10
          PyZMQ: 14.0.1
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: Ubuntu 14.04 trusty
        machine: x86_64
        release: 3.13.0-105-generic
         system: Linux
        version: Ubuntu 14.04 trusty

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Salt git.commit module entry point and reproduce the SLS case in a repository with no changes. Compare its handling of Git's clean-working-tree result with the direct command; done means applying the state no longer reports an exception when there is nothing to commit.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.