written small snippet to automate git add , commit and push using pythongit.
def git_commit_push(self):
repoDir = self.backupRepositoryPath
repo = git.Repo( repoDir )
print repo.git.status()
repo.git.add('--all')
print repo.git.status()
repo.git.commit( m='pusing for backup' )
repo.git.push()
print repo.git.status()
Need to add below mentioned check points
Please help writing the if condition for these two check points.
Regards, Prasad
Logic is tuned here...
def git_commit_push(self):
repoDir = self.backupRepositoryPath
repo = git.Repo( repoDir )
print repo.git.status()
repo.git.add('--all')
changedFiles = repo.index.diff("HEAD")
print "====================================="
print "changedFiles are :", changedFiles
print "====================================="
if ( changedFiles ):
repo.git.commit( m='JenkinsBackup' )
repo.git.push()
else:
print "No files updated"