Skip to content

Commit

Permalink
skein push will cancel commit if the message does not change
Browse files Browse the repository at this point in the history
  • Loading branch information
herlo committed Dec 31, 2011
1 parent 5b2f4d7 commit cfa0f23
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion conf/skein.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 19 additions & 20 deletions skein/pyskein.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand All @@ -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
Expand Down

0 comments on commit cfa0f23

Please sign in to comment.