add no push option
This commit is contained in:
		@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					import argparse
 | 
				
			||||||
import re
 | 
					import re
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
try: 
 | 
					try: 
 | 
				
			||||||
@ -6,7 +7,7 @@ except ImportError:
 | 
				
			|||||||
    # Python < 3
 | 
					    # Python < 3
 | 
				
			||||||
    from ConfigParser import ConfigParser
 | 
					    from ConfigParser import ConfigParser
 | 
				
			||||||
 | 
					
 | 
				
			||||||
version = "1.0.5"
 | 
					version = "1.0.6"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class SemVer(object):
 | 
					class SemVer(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -103,7 +104,7 @@ class SemVer(object):
 | 
				
			|||||||
    # 2) see if we're merging into a main branch
 | 
					    # 2) see if we're merging into a main branch
 | 
				
			||||||
    # 3) see what type of versioning we should do
 | 
					    # 3) see what type of versioning we should do
 | 
				
			||||||
    # 4) version the repo
 | 
					    # 4) version the repo
 | 
				
			||||||
    def run(self):
 | 
					    def run(self,push=True):
 | 
				
			||||||
        if not self.get_branches():
 | 
					        if not self.get_branches():
 | 
				
			||||||
            raise Exception('No merge found')
 | 
					            raise Exception('No merge found')
 | 
				
			||||||
        if self.main_branch not in self.main_branches:
 | 
					        if self.main_branch not in self.main_branches:
 | 
				
			||||||
@ -112,12 +113,16 @@ class SemVer(object):
 | 
				
			|||||||
            raise Exception('No git flow branch found')
 | 
					            raise Exception('No git flow branch found')
 | 
				
			||||||
        self.setup_git_user()
 | 
					        self.setup_git_user()
 | 
				
			||||||
        self.version_repo()
 | 
					        self.version_repo()
 | 
				
			||||||
 | 
					        if push:
 | 
				
			||||||
            self.commit_and_push()
 | 
					            self.commit_and_push()
 | 
				
			||||||
        return self
 | 
					        return self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main():
 | 
					def main():
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        SemVer().run()
 | 
					        parser = argparse.ArgumentParser(description='Bump Semantic Version.')
 | 
				
			||||||
 | 
					        parser.add_argument('-n','--no-push', help='Do not try to push', action='store_false', dest='push')
 | 
				
			||||||
 | 
					        args = parser.parse_args()
 | 
				
			||||||
 | 
					        SemVer().run(push=args.push)
 | 
				
			||||||
    except Exception as e:
 | 
					    except Exception as e:
 | 
				
			||||||
        print(e)
 | 
					        print(e)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										3
									
								
								setup.py
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								setup.py
									
									
									
									
									
								
							@ -98,7 +98,8 @@ setup(
 | 
				
			|||||||
    # requirements files see:
 | 
					    # requirements files see:
 | 
				
			||||||
    # https://packaging.python.org/en/latest/requirements.html
 | 
					    # https://packaging.python.org/en/latest/requirements.html
 | 
				
			||||||
    install_requires=[
 | 
					    install_requires=[
 | 
				
			||||||
        'bumpversion==0.5.3'
 | 
					        'bumpversion==0.5.3',
 | 
				
			||||||
 | 
					        'argparse>=1.2.1'
 | 
				
			||||||
    ],
 | 
					    ],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # List additional groups of dependencies here (e.g. development
 | 
					    # List additional groups of dependencies here (e.g. development
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user