* GITFNS, COMPAREDIRECTORIES: more on renaming and copying * MODERNIZE: use Wborder for the top for windows without titles * DIRECTORY: DEPTH as a parameter * FILEPKG: EDITCALLERS does FILDIR if FILES contains * * GITFNS: Don't error on a non-existent "deleted" file
52 lines
13 KiB
Plaintext
52 lines
13 KiB
Plaintext
Medley GITFNS2
|
||
|
||
4
|
||
|
||
1
|
||
|
||
GITFNS
|
||
1
|
||
|
||
4
|
||
|
||
By Ron Kaplan
|
||
This document was created in January 2022.
|
||
|
||
GITFNS provides a Medley-oriented interface for comparing the files in two different branches of a git repository. This makes it easier to understand what functions or other definitions have changed in a Lisp source file, or what text has changed in a Tedit file. This may be particularly helpful in evaluating the changes in a pull request.
|
||
Separately, GITFNS also provides tools and conventions for bridging between git's file-oriented style of development and version control and Medley's residential development style with its own version control conventions. GITFNS allows for intelligent comparisons between Lisp source files,Tedit files, and text files in a local git clone and a local Medley-style working directory, and for migrating files to and from the git clone and the working directory.
|
||
|
||
Comparing directories and files in different git branches
|
||
In its simplest application, GITFNS is just an off-to-the-side add-on to whatever work practices the user has developed with respect to a local git clone. Its only advantage is to allow for more interpretable git-branch comparisons, especially for PR's. This is enabled once GITFNS is made aware of the local-machine location of the cloned repository. The default assumption is that the variable MEDLEYDIR holds the path to the top-level of the local clone. That becomes the path-prefix for the pseudohost {GIT} (see lispusers/PSEUDOHOSTS). {GIT} is then used as the default handle for local/ and origin/ branch comparisons. Just for clarity (and for compatibility with the additional capabilities described below), the variable GITMEDLEYHOST is set to MEDLEYDIR, and GITMEDLEYHOST is set to {GIT}. {GIT} defaults to a pseudohost on the {UNIX} file device, so it provides a git-like case-sensitive unversioned file system.
|
||
The main use-case is the Lisp-oriented file comparisons for pull-request approval. These comparisons are provided by the prc ("pull request compare") Medley executive command:
|
||
prc (branch) (DRAFT) [command]
|
||
This compares the files in branch against the files in origin/master. Thus, suppose that a pull request has been issued on github for a particular branch, say branch rmk15. Then
|
||
prc rmk15
|
||
brings up a lispusers/COMPAREDIRECTORIES browser for the files that currently differ between origin/rmk15 and origin/master. If the selected files are Lisp source files, the Compare item on the file browser menu will show the differences in a lispusers/COMPARESOURCES browser. The differences for other file types will be shown in a lispusers/COMPARETEXT browser.
|
||
If branch is not specified and the shell command gh is available, then a menu of open pull-request branches will be provided. If gh is not available, the menu will offer all known branches. If the optional DRAFT is provided, then the menu will include draft PR's as well as open ones.
|
||
Note that the comparison that this provides is essentially read-only: any comments, approvals, or merges of the branch must be specified using the normal Medley-external git interfaces and commands.
|
||
|
||
prc is the special case of the more general bbc command ("branch-branch compare) for comparing the files in any two branches:
|
||
bbc branch1 branch2 [command]
|
||
This compares the files in branch1 and branch2, for example
|
||
bbc rmk15 lmm12 (local)
|
||
This will compare the files in origin/rmk15 and origin/lmm12. branch1 defaults to the origin files of the currently checked out branch, the second defaults to origin/master. If local is non-NIL, then a branch that has neither local/ or origin/ prepended will default to local (e.g. local/rmk15) instead of origin/. Local refers to the files that are currently in the clone directory, which may not be the same as the origin files, depending on the push/pull status.
|
||
|
||
The command cob ("check out branch") checks out a specified branch:
|
||
cob branch [command]
|
||
This checks out branch and then executes git pull. The branch parameter may also be a local branch, T (= my current branch), or NEW/NEXT (= my next branch). My current branch is a the branch named <initials>nnn, e.g. rmk15. The initials are the value of INITIALS as used for SEDIT time stamps, and nnn is the largest of the integers of all of the branches beginning with those initials. If branch is NEW or NEXT, then a new initialed branch is created and becomes the user's current branch. Its number is one greater than the largest number of previous initialed branches.
|
||
If branch is not provided, a menu of locally available branches pops up.
|
||
|
||
The currently checked out branch is obtained by the b? command:
|
||
b? [command]
|
||
|
||
Correlating git source control with separate Medley development
|
||
It is generally unsafe to do Medley development by operating with files in the local clone repository. Medley provides a residential development environment that integrates tightly with the local file system. It is important to have consistent access to the source files of the currently running system, especially for files whose contents have been only partially loaded. A git pull or a branch switch that introduces new versions of some files or removes old files altogether can lead to unpredictable disconnects that are hard to recover from. This is true also because development can go on in the same Medley memory image for days if not weeks, so it is important to have explicit control of any file version changes.
|
||
GITFNS mitigates the danger by conventions that separate the files in the git clone from the files in the working Medley development directory. The Medley development source tree is referred to as "My Medley" as opposed to the source-tree of the locally checked out branch of the repository ("Git Medley"). My Medley resides at a path provided by the Unix variable MYMEDLEYDIR, obtained by (UNIX-GETENV "MYMEDLEYDIR"), and (UNIX-GETENV "GITMEDLEYDIR") gives the location of the git clone . (If MYMEDLEYDIR is not defined, then my Medley source tree is assumed to exist at MEDLEYDIR.) MYMEDLEYDIR is the path-prefix for a pseudohost {MM} and GITMEDLEYDIR is the prefix for {GIT}. These pseudohosts are the respective values of the variables MYMEDLEYHOST and GITMEDLEYHOST. {MM} defaults to a pseudohost on the case insensitive, versioned {DSK} file device, {GIT} defaults to {UNIX}.
|
||
The Medley variables for directory search paths (DIRECTORIES, LISPUSERSDIRECTORIES, FONTDIRECTORIES, etc.) all have MEDLEYDIR as a prefix, and the development environment makes no reference to GITMEDLEYDIR. Any back and forth transfer of information between the git clone and Medley development must be done by explicit synchronization actions. Crucially, Medley-updated files do not appear in the clone directories and new clone files do not move to the Medley directories without user intervention.
|
||
The files in My Medley and Git Medley can be compared with the gmc ("git-my-medley compare") command:
|
||
gmc subdirectories [command]
|
||
This produces a browser for all the files in the corresponding Medley subdirectories that differ from the files in the currently checked out branch of the git clone. If subdirectories is omitted, it defaults to sources library lispusers. If it is ALL, then files in all My Medley subdirectories are examined.
|
||
In addition to the commands for comparing and viewing files, the menu for this browser also has commands for copying files from the git clone {GIT} to My Medley and deleting files from {MM}. If the master branch is current, then the menu has no commands to change the files in the clone. The browser will show those files that have been updated from a recent merge, and they can individually be copied to new My Medley versions in order to realign the two source trees. If the comparison is with a different branch, say the user's current staging branch, copying files from My Medley to git or deleting git files will set git up for future commits.
|
||
Note that the menu item for deleting My Medley files will cause all version to be removed, not just the latest one, to avoid the possibility that an earlier one is revealed. Deletion for My Medley files is also accomplished by renaming to a {MM}<deletion> subdirectory so that they can be recovered if a deletion is in error. Files in the git-clone are removed from the file system immediately, since git provides its own recovery mechanism for those files.
|
||
GITFNS does not (yet?) include functions for commits, pushes, or merges for updating the remote repository. Those have to be done outside of Medley through the usual github interfaces, as guided by the information provided by the comparisons.
|
||
|