Friday, 11 May 2018

Merge Between Two Branches in git


To Merge the current origin/master into a feature branch
----------------------------------------------------------

We need to ensure that the code that your changes in the feature branch still work with the latest changes that have been applied to master whilst you have been developing your feature.

- Make sure you have the latest code from the remote with: git fetch
- Make sure you are on your LOCAL FEATURE branch that was created using the REMOTE FEATURE branch: git checkout myFeature
- Make sure your LOCAL FEATURE branch is in line with the HEAD of the REMOTE FEATURE branch: git rebase origin/myFeature
- Merge origin/master to your LOCAL FEATURE branch: git merge origin/master

You now have the latest changes from the REMOTE MASTER in your LOCAL FEATURE branch.


- Perform a FULL build and test
- If there are any issues fix them then git add … etc… and finally a git commit
- Push this new commit to the remote branch: git push origin HEAD:refs/for/myFeature
- You may have to manually add a gerrit change id to the commit message as the 'git hook' that automatically adds this is setup for the commit operation and not the merge operation.

You now have your feature merged together with the latest code from origin/master pushed to you REMOTE FEATURE branch.

- Request QA to generate a new build off the FEATURE BRANCH, to run fitness tests against it and do any other necessary testing

Merging code to master (http://www.gitguys.com/topics/merging-branches-without-a-conflict/)

To merge the current feature branch into origin/master  :
------------------------------------------------------------

i)     Make sure you have the latest code from the remote with git fetch

ii)    Make sure you are on local master git

iii)   Make sure your local master is in line with the HEAD of the origin/master git rebase origin/master

iv)    This step has an extra flag it is not the same as step iv) in the previous steps - Merge the feature branch locally git merge –no-ff origin/appliedratecube

v)     If there are any issues fix them then git add … etc… and finally a git commit

vi)    Push this new commit to origin/master (you may have to manually add a gerrit change id to the commit message) git push origin HEAD:refs/for/master

Friday, 24 January 2014

Executing a OS Commands-copy,delete,extract tar using Python

Executing a OS Commands-copy,delete,extract tar using Python
'''
Created on 24 Jan 2014

@author: Xavier Adaickalam
@note: execute_caommand.py
'''
import os
import shutil
import tarfile
import glob
import subprocess

def delete_files(ljs_dir):
    print('Deleting Files...')
    delete_directory(ljs_dir +'/*')
    print('Deleting Files...DONE')

def delete_directory(dir_name):
    print("Deleting " + dir_name)
    files = glob.glob(dir_name)
    for f in files:
        if os.path.isdir(f):
            shutil.rmtree(f)
            print('Deleted Directory :'+f)
        else:
            os.remove(f)
            print('Deleted File :'+f)

def extract_tar(filename,to_dir):
    print('Extracting :'+filename + ' to ' + to_dir)
    tfile = tarfile.open(filename,'r') 
    for tarinfo in tfile:
        #print(tarinfo.name)
        tfile.extract(tarinfo,to_dir)             
    #tfile.exctractall()    
    tfile.close()
    print('Completed Extraction :'+filename)
    
def copy_file(from_dir,to_dir):
    files = glob.glob(from_dir + '/*.war')
    for f in files:
        print('Copying file :' + f + ' to :' +to_dir)
        shutil.copy(f, to_dir)

def run_command(cmd,directory):
    subprocess.check_call(cmd,cwd=directory)
    
if __name__ == '__main__':
    cmd1 = [ 'ls', '-a']
    run_command(cmd1,'.')

Generating a CSV content using Python

Python has a library module called csv which can be used to generate a sample data in csv format.
'''
Created on 24 Jul 2013

@author: Xavier Adaickalam
@note: genetate_data_csv.py
'''
import csv

def generate_data(): 
    try:
        f = open('data.csv', 'wb')
        data_set = []
        data_props = ['ID','NAME','FIRST_NAME','LAST_NAME','MIDDLE_NAME','NICK_NAME','PROFILE','PICTURE',\
                    'WEBSITE','EMAIL', 'EMAIL_VERIFIED', 'GENDER', 'DATE_OF_BIRTH', 'ZONEINFO', \
                    'LOCALE','PHONE_NUMBER','STREET_ADDRESS','CITY','REGION','COUNTRY','POSTAL_CODE',\
                    'MARITAL_STATUS']
        try :
            contentwriter = csv.writer(f,delimiter=',', quotechar='|', quoting=csv.QUOTE_MINIMAL)
            for i in range(100):
                for a in data_props:
                    data_set.append(a + '-'  + str(i))
                contentwriter.writerow(data_set)
                data_set=[]
        finally:
            f.flush()
            f.close();
    except IOError:
        pass
if __name__ == '__main__':
    generate_data()