def showStatus(): un = helper.getUserNamePassword(configfilename) print 'Current status' print 'Github username:\t\t' + un['github_username'] print 'Github password:\t\tl3mmu$_is_cool_and' print 'Repository:\t\t\t' + helper.getStatus(configfilename,'current_repo') print 'Issue:\t\t\t\t' + helper.getStatus(configfilename,'current_issue') print 'Repository directory: \t\t' + helper.getStatus(configfilename,'repo_local_location') print 'Meta repository directory:\t' + helper.getStatus(configfilename,'repo_meta_local_location')
def createBranch(branchName): git = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_local_location')) git_meta = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_meta_local_location')) try: git_meta.checkout('master') except: print 'FATAL: Unable to switch to master branch of meta repository. .. exiting' exit(2) try: git_meta.pull() except: print 'WARNING: Unable to pull latest updates of master of the meta repository on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Did not switch to branch ' + branchName exit(2) try: git.checkout('master') except: print 'FATAL: Unable to switch to master branch of submodule ... exiting' exit(2) try: git.pull() except: print 'WARNING: Unable to pull latest updates of master of the submodule on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Did not switch to branch ' + branchName exit(2) try: git.checkout(branchName) except: git.checkout('-b',branchName) try: git.push('origin',branchName) except: print 'WARNING: Unable to push ' + branchName + ' to Github' if int(git.version().split(' ')[2].split('.')[1]) < 8: try: git.branch('--set-upstream','origin',branchName) except: print 'WARNING: Unable to set upstream' else: try: git.branch('-u','origin/'+branchName) except: print 'WARNING: Unable to set upstream'
def showStatus(): un = helper.getUserNamePassword(configfilename) print 'Current status' print 'Github username:\t\t' + un['github_username'] print 'Github password:\t\tl3mmu$_is_cool_and' print 'Repository:\t\t\t' + helper.getStatus(configfilename, 'current_repo') print 'Issue:\t\t\t\t' + helper.getStatus(configfilename, 'current_issue') print 'Repository directory: \t\t' + helper.getStatus( configfilename, 'repo_local_location') print 'Meta repository directory:\t' + helper.getStatus( configfilename, 'repo_meta_local_location')
def createIssue(): issue_title = raw_input('Title:') issue_description = raw_input('Description:') sure= raw_input('Are you sure you want to this issue for repository ' + helper.getStatus(configfilename,'current_repo') + ' [y/n]:') if not sure == 'y': print 'Canceld by user input' assignee = gh.get_user(cred['github_username']) repo = getCurrentRepo() yours = raw_input('Assign it to you name? [y/n]:') if yours == 'y': issue = repo.create_issue(issue_title,issue_description,assignee) print 'Issue created' want_it_now = raw_input('Do you want work on this issue now? [y/n]:') if want_it_now == 'y': #helper.setStatus(configfilename,'current_issue',str(issue.number)) #print 'TO BE IMPLEMENTED: Created branch #' + str(issue.number) + ' in ' + helper.getStatus(configfilename,'current_repo') openIssue(issue.number) print 'Happy coding!' else: issue = repo.create_issue(issue_title,issue_description) print 'Issue created'
def commit(message): git = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_local_location')) git.add('*.*') git.commit('-a',m=message) try: git.push() except: print 'WARNING: Unable to push latest commit to github'
def test(): git = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_local_location')) git_meta = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_meta_local_location')) branchName = '#' + helper.getStatus(configfilename,'current_issue') metaBranchName = helper.getStatus(configfilename,'current_repo') + branchName try: git_meta.checkout('master') except: print 'ERROR: Unable to checkout to master branch of meta repository' exit(2) try: git_meta.pull() except: print 'ERROR: Unable to pull latest changes of the meta repository from Github' exit(2) try: git_meta.checkout(metaBranchName) except: git_meta.checkout('-b',metaBranchName) git.checkout(branchName) git_meta.add(helper.getStatus(configfilename,'repo_local_location')) git_meta.commit('-a',m='Changed reference of module ' + helper.getStatus(configfilename,'current_repo') + 'to HEAD of ' + branchName) try: git_meta.push('origin',metaBranchName) except: print 'WARNING: Unable to push ' + metaBranchName + ' to Github' if int(git_meta.version().split(' ')[2].split('.')[1]) < 8: try: git_meta.branch('--set-upstream','origin',metaBranchName) except: print 'WARNING: Unable to set upstream' else: try: git_meta.branch('-u','origin/'+metaBranchName) except: print 'WARNING: Unable to set upstream' print 'Testing branch created. Jenkins will automaticly test it. A manual functionality test might still by handy at the moment '
def mergeWithMaster(): git = sh.git.bake( _cwd=helper.getStatus(configfilename, 'repo_local_location')) git_meta = sh.git.bake( _cwd=helper.getStatus(configfilename, 'repo_meta_local_location')) issue = helper.getStatus(configfilename, 'current_issue') print 'You will merge ticket #' + issue + ' of repository ' + helper.getStatus( configfilename, 'current_repo') + ' to the master and meta master.' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git_meta.checkout('master') except: print 'FATAL: Unable to switch to master branch of meta repository. .. exiting' exit(2) try: git_meta.fetch() except: print 'WARNING: Unable to fetch latest updates of master of the meta repository on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git_meta.checkout( helper.getStatus(configfilename, 'current_repo') + '#' + issue) except: print 'FATAL: Unable to switch to ' + helper.getStatus( configfilename, 'current_repo' ) + '#' + issue + ' branch of meta repository. .. exiting' exit(2) try: git_meta.fetch() except: print 'WARNING: Unable to fetch latest updates of ' + helper.getStatus( configfilename, 'current_repo') + '#' + issue + ' of the meta repository on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git.checkout('master') except: print 'FATAL: Unable to switch to master branch of submodule ... exiting' exit(2) try: git.fetch() except: print 'WARNING: Unable to fetch latest updates of master of the submodule on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git.checkout('#' + issue) except: print 'FATAL: Unable to switch to #' + issue + ' branch of submodule ... exiting' exit(2) try: git.fetch() except: print 'WARNING: Unable to fetch latest updates of #' + issue + ' of the submodule on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) print 'Merging master --> #' + issue git.merge('master') print 'Merging #' + issue + ' --> master' git.checkout('master') git.merge('#' + issue) print 'Updating submodule link to head of submodule' git_meta.checkout('master') git_meta.add(helper.getStatus(configfilename, 'repo_local_location')) git_meta.commit('-a', m='Changed reference of module ' + helper.getStatus(configfilename, 'current_repo') + 'to HEAD of #' + issue) # if think it needs to be this, but it is contra with workflow documentation if not raw_input('Push changes to Github? [y/n]') == 'y': print 'Canceld by user' exit(2) git.push('origin', 'master') git_meta.push('origin', 'master')
def mergeWithMaster(): git = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_local_location')) git_meta = sh.git.bake(_cwd=helper.getStatus(configfilename,'repo_meta_local_location')) issue = helper.getStatus(configfilename,'current_issue') print 'You will merge ticket #' + issue + ' of repository ' + helper.getStatus(configfilename,'current_repo') + ' to the master and meta master.' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git_meta.checkout('master') except: print 'FATAL: Unable to switch to master branch of meta repository. .. exiting' exit(2) try: git_meta.fetch() except: print 'WARNING: Unable to fetch latest updates of master of the meta repository on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git_meta.checkout(helper.getStatus(configfilename,'current_repo')+'#'+issue) except: print 'FATAL: Unable to switch to '+helper.getStatus(configfilename,'current_repo')+'#'+issue+' branch of meta repository. .. exiting' exit(2) try: git_meta.fetch() except: print 'WARNING: Unable to fetch latest updates of '+helper.getStatus(configfilename,'current_repo')+'#'+issue+' of the meta repository on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git.checkout('master') except: print 'FATAL: Unable to switch to master branch of submodule ... exiting' exit(2) try: git.fetch() except: print 'WARNING: Unable to fetch latest updates of master of the submodule on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) try: git.checkout('#'+issue) except: print 'FATAL: Unable to switch to #'+issue+' branch of submodule ... exiting' exit(2) try: git.fetch() except: print 'WARNING: Unable to fetch latest updates of #'+issue+' of the submodule on Github' if not raw_input('Continue? [y/n]') == 'y': print 'Canceld by user input' exit(2) print 'Merging master --> #' + issue git.merge('master') print 'Merging #' + issue + ' --> master' git.checkout('master') git.merge('#'+issue) print 'Updating submodule link to head of submodule' git_meta.checkout('master') git_meta.add(helper.getStatus(configfilename,'repo_local_location')) git_meta.commit('-a',m='Changed reference of module ' + helper.getStatus(configfilename,'current_repo') + 'to HEAD of #' + issue) # if think it needs to be this, but it is contra with workflow documentation if not raw_input('Push changes to Github? [y/n]') == 'y': print 'Canceld by user' exit(2) git.push('origin','master') git_meta.push('origin','master')
def getCurrentIssue(): return getIssue(int(helper.getStatus(configfilename,'current_issue')))
def setComment(commentText): repo = getCurrentRepo() issueID = helper.getStatus(configfilename,'current_issue') issue = getIssue(int(issueID)) issue.create_comment(commentText)
def getCurrentRepo(): current_repo = getGithubRepo(helper.getStatus(configfilename,'current_repo')) return current_repo