Creating PDM User Defined Options for Git

<< Click to Display Table of Contents >>

Navigation:  Hooking Up to PDM and RDi  >

Creating PDM User Defined Options for Git

If you are a PDM user and also still use SEU for editing then you will probably want to create a few PDM user-defined options to access the iForGit functionality to version control your IBM i source members that live in source files.

 

The strategy for source files would typically be to maintain your source in place in source files, yet start using the source control of git to get out of the habit of having to make source member copies when making changes, which leaves old versions all over the place.

 

Source members and versions can simply be stored in a local shared IFS repository directory or they can be pushed to a remote git server if you have one established.

 

Getting Started with PDM and Git

The first thing you need to do is STRPDM and then press Shift-F4 (F16) to display the user defined options.

 

Press F6 to create a new User-Defined option.

 

 

Exporting and Import Source Member Changes from a Git Repository

The SRCTOGIT command is used to commit member changes to a git repository. This is the primary command most developers will use to commit changes for a source member to the selected library's git repository from PDM, RDI or VS Code.

 

The SRCFRMGIT command can get back the most recent comcmint from a repository.

 

 

Source Member Export/Commit and Import of Recent Version from Git Repository

The following 2 user defined options GE and GI are used for export and import of source members with git version control using a shared local repository IFS folder

 

Option GE - Export Source Member to Git - Use this option to send and commit current source member version to the git repository.

 

Option *COMMIT will just commit to the IFS repository.

 

Option *COMMITSYNC will commit to the IFS repository and push changes to your remote git server is configured.

 

Option: GE

 

Command: IFORGIT/SRCTOGIT SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA)

SRCHEADER(*YES) SRCDATSEQ(*NO) REPLACE(*YES)  EDITOPT(*NONE)

VALIDREPO(*YES) IFSMKDIR(*YES) INITREPO(*YES) COMMITOPT(*COMMIT) COMMENT(*DATEUSER)  

                                                                               

 

 

Option GI - Import Source Member from Git Repository - Use this option to import most recent commit back to the library source member and overlay the existing source member. It's a great way to recover an entire source member if something was messed up during editing.

 

Note: Use the SRCGITCMD command with the *CHECKOUT option to check out a specific source member version commit based on its source hash instead of just grabbing the most reent version.

 

Option: GI

 

Command: IFORGIT/SRCFRMGIT IFSREPODIR(*LIBREPODTAARA) FROMIFSFIL(*LIBFILEPATH)

SRCFILE(&L/&F) SRCMBR(&N) SRCTYPE(&T) SRCHEADER(*YES) SRCDATSEQ(*NO)

REPLACE(*YES) EDITOPT(*NONE) VALIDREPO(*YES) COMMITOPT(*COMMIT)        

 

 

 

Granular Git Member Processing via CL Command SRCGITCMD

 

The SRCGITCMD command can be used to view or check out specific old versions of a source member using the the SRCGITCMD CL command itself in a process or interactively as a PDM option or RDI user action. Perform tasks such as Viewing Git History, Performing Diff or Blame operations and Checking Out/Restoring an Old Versions to a library for viewing or editing.

 

 

Option GL - Perform a Git Log on Source Member

 

Perform a git log command to see how many times a member has been committed and determine the git commit hash for checking out a selected member version from your git repository with the *BLAME option.

 

Once you determine the hash version you want for a source member, just copy to the clipboard and paste it into the appropriate prompt for Git Checkout, etc.

 

Option: GL

 

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*LOG) DSPSTDOUT(*YES)

 

 

 

Option GC - Perform Git Checkout and View of Source Member

 

Perform a git checkout command to check out a selected older version of a source member to a selected source physical file for viewing or working with it via PDM or RDI. By default the source member gets checked out to file: QTEMP/TMPSOURCE member: TMPSOURCE for being viewed via SEU and is displayed via SEU after checkout.

 

If you want to select a specific git hash to check out, run the GL option first to determine which hash version you want. Or determine the hash from your git repository and then prompt for the SRCGITCOMD using F4 to enter the specific hash or partial hash to retrieve from the repo. Blanks in SRCHASH will get the most recent commit version and display it.

 

Note: This command can also be used to checkout the selected version and restore to the original source location or another specific work library iF the DESTFILE/DESTMBR parameters are specified.

 

Option GC

 

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*CHECKOUT) SRCHASH(' ') DSPSTDOUT(*NO) DSPCHKOUT(*BROWSE)

 

 

 

Option GB - Perform Git Blame on Source Member

Perform a git blame command to show a consolidated view of the selected source member commits to determine what older version you may want to view or restore. Date info and the user name who committed the changes for each version is listed along with the source hash id.

 

Option GB

 

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*BLAME) SRCHASH(*MOSTRECENT) DSPSTDOUT(*YES)

 

 

 

Option GD - Perform Git Diff on Selected Version

Perform a git diff command for a selected hash to do a diff based on the most recent version compared with the selected hash version. You must specify a member commit hash value or *MOSTRECENT in the SRCHASH parameter to show the most recent version file version.

 

Option GD

 

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*DIFF) SRCHASH(*MOSTRECENT) DSPSTDOUT(*YES)

 

 

 

Option GS - Perform Git Show on a Member

 

Perform a git show command for a selected hash to show that version of the source member. *MOSTRECENT for the SRCHASH will show the most recent commit.

 

Option GS

 

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCHASH(*MOSTRECENT) SRCOPTION(*SHOW) DSPSTDOUT(*YES)

 

 

 

Source Member Export/Commit and Import of Recent Version from Git Repository

The following 2 user defined options SE and SI are used for simple export and import of source members without git version control

 

Option SE - Export source member to IFS with SRCTOGIT without committing to a git repository by using *NOCOMMIT for the COMMITOPT parameter. Good for simple source export with source info header and want to keep source in the IFS with NO version control. You can F4 to prompt the command and this option can be performed on one or more selected source members.

                                                                               

Option: SE

 

Command: SRCTOGIT SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA)

SRCHEADER(*YES) SRCDATSEQ(*NO) REPLACE(*YES) EDITOPT(*NONE)

VALIDREPO(*NO) IFSMKDIR(*YES) INITREPO(*NO) COMMITOPT(*NOCOMMIT)                    

                                                                               

 

Option SI - Import source from IFS to source file with SRCFRMGIT without committing or pulling from a git repository by using *NOCOMMIT for the COMMITOPT parameter. Good for simple source import using source info header and keeping source in the IFS with NO version control. You can F4 to prompt the command and this option can be performed on one or more selected source members.

 

Option: SI

                                                                               

Command: SRCFRMGIT IFSREPODIR(*LIBREPODTAARA)

FROMIFSFIL(*LIBFILEPATH) SRCFILE(&L/&F) SRCMBR(&N)

SRCTYPE(&T) SRCHEADER(*YES) SRCDATSEQ(*NO) REPLACE(*YES)

EDITOPT(*NONE) VALIDREPO(*NO) COMMITOPT(*NOCOMMIT)            

 

 
SEU Related Editing with Git Version Control

These two user options can be used to provide a seamless development experience for SEU development users on IBM i while also introducing Git source control into the environment.

 

Instead of selecting option 2 for editing, the user would specify E to use STRSEUGIT instead of STRSEU to edit a source member.

Instead of selecting option 5 for browsing, the user would specify B to use STRSEUGIT instead of STRSEU to edit a source member.

 
Note: There are ways to hook up STRSEUGIT to PDM options 2 and 5. However they require copying a few IBM i system commands which is generally not standard practice. Reach out if you need discussion on hooking up to options 2 and 5 in PDM for editing automatically with STRSEUGIT if your developers don't like the idea of using user defined options E and B for editing.

 

This edit and version control workflow should result in a seamless editing process for IBM i developers who want to still use SEU for editing and automatically make backup copies of their source members in a Git repository after editing. All in one edit step. This is about as close to the classic editing experience as you can get.

 

Tip: I recommend not using the STRSEUGIT command. Instead I recommend getting comfortable with using the GE and GI PDM options to commit or pull git changes before and after editing if developers plan to continue using SEU. They can continue to use SEU option 2 and 5 for editing instead of using the STRSEUGIT CL command.

 

 

 

Option E - Edit source member with SEU. Get most recent version from Git repository and Edit the source member via SEU using the STRSEUGIT command. This command will automatically make sure any previous changes are committed and pulled from the repository before editing, then it will launch SEU for editing and after editing any changes are then recommitted and synced to the local and remote repository as needed which results is a classic seamless editing experience without the need to make source backup copies all the time. All SEU changes will always be automatically version controlled if a library is enabled for Git.

 

Option: E

                                                                               

Command: IFORGIT/STRSEUGIT SRCFILE(&L/&F) SRCMBR(&N) TYPE(&T) OPTION('2')

SRCFRMGIT IFSREPODIR(*LIBREPODTAARA) FROMIFSFIL(*LIBFILEPATH)

SRCFILE(&L/&F) SRCMBR(&N) SRCTYPE(&T) SRCHEADER(*YES) SRCDATSEQ(*NO)

REPLACE(*YES) EDITOPT(*NONE) VALIDREPO(*YES) COMMITOPT(*COMMIT)        

 

 

 

 

Option B - Browse source member with SEU. Get most recent version from Git repository and Browse the source member via SEU using the STRSEUGIT command. This command will automatically make sure any previous changes are committed and pulled from the repository before browsing, then it will launch SEU for browsing and after browsing any changes are then recommitted and synced to the local and remote repository as needed which results is a classic seamless browsing experience without the need to make source backup copies all the time. All SEU changes will be always be automatically version controlled if a library is enabled for Git.

 

Option: B

                                                                               

Command: IFORGIT/STRSEUGIT SRCFILE(&L/&F) SRCMBR(&N) TYPE(&T) OPTION('5')

SRCFRMGIT IFSREPODIR(*LIBREPODTAARA) FROMIFSFIL(*LIBFILEPATH)

SRCFILE(&L/&F) SRCMBR(&N) SRCTYPE(&T) SRCHEADER(*YES) SRCDATSEQ(*NO)

REPLACE(*YES) EDITOPT(*NONE) VALIDREPO(*YES) COMMITOPT(*COMMIT)        

 

 

Granular Git Member Processing such as Viewing Git History, Performing Diff or Blame operations and  Checking Out/Restoring an Old Versions

The SRCGITCMD command can be used to view or check out old versions of a source member using the the SRCGITCMD CL command itself in a process or interactively as a PDM option or RDI user action:

 

 

Option GL - Perform a git log command to see how many times a member has been committed and determine the git commit hash for checking out the member from your git repository.

 

Option: GL

                                                                               

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*LOG) DSPSTDOUT(*YES)                                          

 

 

 

Option GC - Perform a git checkout command to check out a selected older version of a source member to a selected source physical file for viewing or working with it via PDM or RDI. By default the source member gets checked out to file: QTEMP/TMPSOURCE member: TMPSOURCE for being viewed via SEU.

 

Note: This command can also be used to checkout the selected version and restore to the original source location or another work library if the DESTFILE/DESTMBR parameters are specified.

 

Option: GC

 

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*CHECKOUT) SRCHASH(' ') DSPSTDOUT(*NO) DSPCHKOUT(*BROWSE)              

 

 

 

 

Option GB - Perform a git blame command to show a consolidated view of the selected source member commits to determine what older version you may want to view or restore. The commit info and hash levels and user name info shows in the listing. Then if needed, you can perform a separate git diff command (Option GD) instead for a selected hash to see what has changed.

 

Option: GB

                                                                               

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*BLAME) SRCHASH(*MOSTRECENT) DSPSTDOUT(*YES)    

 

 

 

Options GD - Perform a git diff command for a selected hash to do a diff based on the most recent version compared with the selected hash version. You must specify a member commit hash value or *MOSTRECENT in the SRCHASH parameter to show the most recent version file version.  

 

Option: GD

                                                                               

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCOPTION(*DIFF) SRCHASH(*MOSTRECENT) DSPSTDOUT(*YES)                  

 

 

 

Options GS - Perform a git show command for a selected hash to show that version of the source member. *MOSTRECENT will show the most recent commit.

 

Option: GS

                                                                               

Command: IFORGIT/SRCGITCMD SRCFILE(&L/&F) SRCMBR(&N) IFSREPODIR(*LIBREPODTAARA) SRCHASH(*MOSTRECENT) SRCOPTION(*SHOW) DSPSTDOUT(*YES)