<< Click to Display Table of Contents >> Navigation: IBM i Git Source Commands > SRCTOGIT - Export Source Member To Git Repo Dir and Commit |
Description
This CL command is used to export source member to IFS repository and commit changes. Can also be used for simple source export as well with *NOCOMMIT options.
This command should be called after editing and saving a source member. The idea is to always keep the local or remote Git repository up to date after editing.
Most often this command may be called via the PDM user defined option GE
Command Example to perform git sync
SRCTOGIT SRCFILE(SRCLIB/SRCFILE)
SRCMBR(SRCMEMBER)
IFSREPODIR(*LIBREPODTAARA)
SRCHEADER(*YES)
SRCDATSEQ(*NO)
REPLACE(*YES)
EDITOPT(*NONE)
VALIDREPO(*YES)
IFSMKDIR(*YES)
INITREPO(*YES)
COMMITOPT(*COMMIT)
COMMENT(*DATEUSER)
AUTHORITY(*INDIR)
Parameters
SRCFILE - Source file and library name for member to export.
SRCMBR - Source member to export.
IFSREPODIR - Destination git repository IFS directory. Use this command along with IFSMKDIR-*YES to auto-create any repository directories. Default: *LIBREPODTAARA
Options
Specific IFS path - If you have a specific git repository directory you want to use, enter it. Example repo name: /gitrepos/lib001
*LIBREPODTAARA - If you have created and set the 255 character GITREPODIR data area with a valid repo IFS path you want to use for this library, then the repo set in GITREPODIR will be used as long as it's not blanks.
*LIBFILEPATH - Create a top level git repository based on a prefix of GIT_ combined with the library name. Example repo name: /GIT_QGPL
*CURRENTREPO - If you are setting the CURGITREPO data area in QTEMP via the SETCURREPO command, then you can use this option. Git repo name used will be whatever you set in CURGITREPO as long as it's not blanks.
SRCHEADER - Include source info header at the top of each source member during export. Default: *YES
Options
*NO - Do not write source header info during export. Only use this if you don't plan to import source members again or don't need to maintain source type and text in standard source files.
*YES - Write source header info during export. This option should normally be set to *YES because the header info is needed during import of source members to maintain the appropriate source type and text when a member is imported.
SRCDATSEQ - Include source dates and sequence numbers during source export to IFS. Default: *NO
Options
*NO - Do not include source dates and sequences. Use this option if you are comfortable not having source date and sequence info in your source member. Most modern developers rely on source code diffs rather than dates info and line numbers to compare source member for changes. Your team needs to be emotionally ready for eliminating source dates and sequences
Note: Eliminating source dates and line sequences will be a cultural decision for your development team to make. Generally we recommend the *NO option for NOT maintaining source lines and dates, which allows IFS source members to be edited from the IFS or a PC with any source editor including notepad, notepad++, vscode and more.
*YES - Write source dates and sequences for each line. This option should normally be set to *YES only if you are using RDI and want to maintain line dates and sequences or you are using SEU and want to maintain line dates and sequences.
Note: If your shop is not culturally ready to make the change and get rid of source dates and line numbers, this option can be used when exporting source members.
REPLACE - Replace existing IFS member if one has been exported previously. Default: *YES.
Options
*NO - Do not replace existing IFS source member.
*YES - Replace existing IFS source member.
EDITOPT - Display or edit IFS file after export. Default: *NONE
Options
*NONE - No editing of the IFS file.
*WRKLNK - Perform a WRKLNK command to locate the file after export.
*DSP - Display IFS file with DSPLNK.
*EDIT - Edit IFS file with EDTF
VALIDREPO - Check if IFS directory is a valid git repository. Default: *YES
*NO - Do not check if IFS directory is already a valid repository before exporting. Use this if simply exporting to the IFS and there is no git repository required.
*YES - Check if IFS directory is already a valid repository before exporting. Use this if the IFS directory needs to be a valid git repository for version control.
IFSMKDIR - Create IFS directory and git repository. Default: *YES
*NO - Do not create IFS repository directory paths automatically.
*YES - Create IFS repository directory paths automatically.
INITREPO - Init git repo after directory create. Default: *YES
*NO - Do not create Git repo after directory path creation.
*YES - Create Git repository right after directory path creation.
**Note: If IFS directory already exists, we DO NOT attempt to initialize the Git repo because one may already exist. A manual review and Git init will be needed to initialize the repository in this case if needed. You can either create your Git repository before running SRCTOGIT or you can let your first call to the SRCTOGIT command create the directories and repository automatically.
COMMITOPT - Commit changes after source member export to IFS. Default: *COMMIT
Options
*COMMIT - Export source member to local git repository directory and commit to local repository in IFS. Use this if you are leaving git changes in the IFS or plan to push them to a remote repository later. This is the default option.
*COMMITSYNC - Export source member to local git repository directory and commit to local repository in IFS. Then pull and merge any remote changes and push them back to the repository. Use this option normally for a full git edit and version life-cycle where the local copies stay in sync with the remote repository at all times.
*COMMITPUSH - Export source member to local git repository directory and commit to local repository in IFS. Then push changes to remote repository. This option only pushes changes, but does not pull and merge remote changes with the local repository.
*GITADD - Export source member to local git repository directory and add/stage to the commit list in local IFS repository. Use this if you want to stage a file for a future commit that will happen later. Good for staging multiple files for a single commit later by the GITCMD CL command with a commit option. Example commit: GITCMD CMDOPTS('-commit -m "My Commit of Many Staged Files')
*NOCOMMIT - Use this option if just simply exporting source member with no intent to commit to git immediately.
COMMENT - Commit comment. Default: *DATEUSER
Enter a commit comment or special value.
*DATEUSER - Write date info and user ID into commit comment automatically.
AUTHORITY - Authority for new file. Default: *INDIR
Options:
*DFT - Owner of file granted *RWX, *PUBLIC will have *NONE.
*INDIR - Use the IFS directory authority to determine permissions.
*FILE - Use the original source file for the FROMMBR to determine authority.
*INDIRFILE - Use the IFS directory authority and then use authority form the FROMMBR.
Note: It may be a good idea to set the IFS directory permissions accordingly and set the AUTHORITY value to *INDIR to make sure the directory permissions are set adequately so there are not any odd member permission issues for any developers access files in this directory. *ALLOBJ authority will bypass any permission issues of course but not usually recommended.