Permalink
Browse files

skein push will cancel commit if the message does not change

  • Loading branch information...
1 parent 5b2f4d7 commit cfa0f237b53b64b00c0da2cab8a5948135e9900d @herlo herlo committed Dec 31, 2011
Showing with 20 additions and 21 deletions.
  1. +1 −1 conf/skein.cfg
  2. +19 −20 skein/pyskein.py
View
@@ -37,7 +37,7 @@ source_exts = tar,gz,bz2,lzma,xz,Z,zip,tff,bin,tbz,tbz2,tgz,tlz,txz,pdf,rpm,jar,
# Used to interpolate defaults above when they don't get used in another category below
[git]
-commit_message=srpm imported for '%(distro)s %(version)s'
+commit_message=### UPDATE/CHANGE ME ### srpm imported for '%(distro)s %(version)s'
# the remote class to manage our upstream repositories
# possible entries are 'GithubRemote', 'GitoliteRemote', or None
remote_module = githubremote
View
@@ -477,7 +477,7 @@ def _upload_source(self, name):
self.logger.info(" nothing to upload for '%s'" % name)
print "nothing to upload for '%s'" % name
- def _commit(self, message=None):
+ def _commit(self, reason=None):
"""Commit is only called in two cases, if there are uncommitted changes
or if there are newly added (aka untracked) files which need to be added to
the local repository prior to being pushed up to the remote repository.
@@ -488,31 +488,30 @@ def _commit(self, message=None):
self.logger.info("||== Committing git repo ==||")
- if not message:
+ reason = None
+ editor = os.environ.get('EDITOR') if os.environ.get('EDITOR') else self.cfgs['skein']['editor']
- editor = os.environ.get('EDITOR') if os.environ.get('EDITOR') else self.cfgs['skein']['editor']
+ tmp_file = tempfile.NamedTemporaryFile(suffix=".tmp")
- tmp_file = tempfile.NamedTemporaryFile(suffix=".tmp")
+ initial_message = self.cfgs['git']['commit_message']
- tmp_file.write(self.cfgs['git']['commit_message'])
- tmp_file.flush()
+ tmp_file.write(initial_message)
+ tmp_file.flush()
- cmd = [editor, tmp_file.name]
+ cmd = [editor, tmp_file.name]
- try:
- p = subprocess.check_call(cmd)
- f = open(tmp_file.name, 'r')
- message = f.read()
-
-# print "r: %s" % message
-# print "i: %s" % self.cfgs['github']['initial_message']
-
- if not message:
- raise SkeinError("Description required.")
+ try:
+ p = subprocess.check_call(cmd)
+ f = open(tmp_file.name, 'r')
+ reason = f.read()
- except subprocess.CalledProcessError:
- raise SkeinError("Action cancelled by user.")
+ if not reason:
+ raise SkeinError("Description required.")
+ elif reason == initial_message:
+ raise SkeinError("Description has not changed.")
+ except subprocess.CalledProcessError:
+ raise SkeinError("Action cancelled by user.")
index = self.repo.index
@@ -538,7 +537,7 @@ def _commit(self, message=None):
if index_changed:
self.logger.info(" committing index")
# commit files added to the index
- index.commit(message)
+ index.commit(reason)
def _push_to_remote(self, name, message=None):
"""Push any/all changes to remote repository

0 comments on commit cfa0f23

Please sign in to comment.