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.

 

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. 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. 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)            

 

 

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 IFS with SRCTOGIT and commit to local IFS git repository. Good for source export with source info header and keeping source in the IFS in a working repository directory under git version control. You can F4 to prompt the command and this option can be performed on one or more selected source members.

                                                                             

Option: GE

                                                                               

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

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

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

                                                                               

Option GI - Import source from IFS to source file with SRCFRMGIT by committing and pulling from a local git repository. Good for source import with source info header and keeping source in the IFS in a working repository directory under git version control. You can F4 to prompt the command and this option can be performed on one or more selected source members.

 

Option: GI

                                                                               

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

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

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

 

 

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.

Instead of selecting option 5 for browsing, the user would specify B.

 
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. This is about as close to the classic editing experience as you can get.

 

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

If you need more granular git repository processing such as diff-ing file versions then you will want to use a PC, Mac or LInux based git client such as Tortoise, SourceTree or some other git client to review changes in the event an old member needs to be pulled from your repository and restored.

 

Restoring an old source member version from repository

The general process for restoring an old version of a file would be to get a copy of it from the repository and place it in the local IFS repo directory (revert). After you have a copy in the repo work directory you should commit the file with GITCMD or use the SRCFRMGIT command with the *COMMIT option to commit and pull the source member back to a source file for editing or other processing.