{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/3245","labels_url":"https://api.github.com/repos/saltstack/salt/issues/3245/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/3245/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/3245/events","html_url":"https://github.com/saltstack/salt/issues/3245","id":9913663,"number":3245,"title":"Support watch with the git state","user":{"login":"kfdm","id":89725,"avatar_url":"https://avatars.githubusercontent.com/u/89725?v=3","gravatar_id":"","url":"https://api.github.com/users/kfdm","html_url":"https://github.com/kfdm","followers_url":"https://api.github.com/users/kfdm/followers","following_url":"https://api.github.com/users/kfdm/following{/other_user}","gists_url":"https://api.github.com/users/kfdm/gists{/gist_id}","starred_url":"https://api.github.com/users/kfdm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kfdm/subscriptions","organizations_url":"https://api.github.com/users/kfdm/orgs","repos_url":"https://api.github.com/users/kfdm/repos","events_url":"https://api.github.com/users/kfdm/events{/privacy}","received_events_url":"https://api.github.com/users/kfdm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2013-01-12T18:56:09Z","updated_at":"2015-01-24T22:05:58Z","closed_at":"2013-01-13T03:13:26Z","body":"I would like to only run a build command if there were new changes in a git repo as in the example\r\n\r\n    my_repo:\r\n      git.latest:\r\n        - name: https://github.com/some/repo.git\r\n        - rev: develop\r\n        - target: /opt/foo\r\n      cmd.run:\r\n        - cwd: /opt/foo\r\n        - name: make install\r\n        - watch:\r\n          - git: my_repo\r\n\r\nRight now, the [git state](https://github.com/saltstack/salt/blob/a07ece5a2af2b1d93f314f6eaf485baa5c3df3eb/salt/states/git.py) does not support mod_watch, so the \"watch\" is converted into a \"require\" so make is run every time.\r\n\r\nWhat would be required to add a mod_watch to git? I've been trying to look at examples of mod watch from the [service state](https://github.com/saltstack/salt/blob/a07ece5a2af2b1d93f314f6eaf485baa5c3df3eb/salt/states/service.py#L372) and [cmd state](https://github.com/saltstack/salt/blob/a07ece5a2af2b1d93f314f6eaf485baa5c3df3eb/salt/states/cmd.py#L552) but it's a little confusing what would be required.\r\n\r\nHow does it determine if a command has changes ? Is it related to the \"changes\" field or something else. The documentation for [watcher function](https://salt.readthedocs.org/en/latest/ref/states/writing.html#watcher-function) is not clear."},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/71339791","html_url":"https://github.com/saltstack/salt/issues/3245#issuecomment-71339791","issue_url":"https://api.github.com/repos/saltstack/salt/issues/3245","id":71339791,"user":{"login":"clintberry","id":464582,"avatar_url":"https://avatars.githubusercontent.com/u/464582?v=3","gravatar_id":"","url":"https://api.github.com/users/clintberry","html_url":"https://github.com/clintberry","followers_url":"https://api.github.com/users/clintberry/followers","following_url":"https://api.github.com/users/clintberry/following{/other_user}","gists_url":"https://api.github.com/users/clintberry/gists{/gist_id}","starred_url":"https://api.github.com/users/clintberry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clintberry/subscriptions","organizations_url":"https://api.github.com/users/clintberry/orgs","repos_url":"https://api.github.com/users/clintberry/repos","events_url":"https://api.github.com/users/clintberry/events{/privacy}","received_events_url":"https://api.github.com/users/clintberry/received_events","type":"User","site_admin":false},"created_at":"2015-01-24T22:05:58Z","updated_at":"2015-01-24T22:05:58Z","body":"I have a linux service that runs from code deployed via git. When the git repo updates on the server, I want the service to restart. This is done via an upstart script. It would be nice to have the watch in place...\r\n\r\n```\r\nmanager-code:\r\n  git.latest:\r\n    - name: git.github.com/manager.git\r\n    - rev: develop\r\n    - target: /opt/manager\r\n    - identity: /root/.ssh/deploy_production.id_rsa\r\n    - require:\r\n        - pkg: git\r\n\r\nmanager:\r\n  service.running:\r\n    - enable: True\r\n    - full_restart: True\r\n    - watch:\r\n      - git: manager-code"}}