Using GIT for Dataflex Development: Difference between revisions

Line 102: Line 102:


You noticed that the commit was really quick, and all panels are blank. You have just created a new repository, told GIT what files to ignore, and committed all other files into the repository.
You noticed that the commit was really quick, and all panels are blank. You have just created a new repository, told GIT what files to ignore, and committed all other files into the repository.
== Setting up the author in GIT ==
When you commit, GIT keeps track of not only the changes, but also of the Author of the changes. In the above initial commit, we did not set this and as DAW is the author this did not really matter, but changed from now on, should have yourself as the author.
To set the Author select  menu  Edit – Options.
[[File:UsingGitforVdfDev_image005.png]]
As you can see there are many settings you can do. For now just set the Username and email address as indicated below with the arrows.
[[File:UsingGitforVdfDev_image006.png]] 
== Making changes and revert back ==
We have our safe initial commit so we can make changes to our hearts content.
Open the Order Entry.sws. Let’s say you want to add the container3D around the objects in the customer view to make it consistent with the other views in this workspace. So I selected in the Design view the Customer Number and Name form, as well as the dbTabDialog. Did Cut, dragged a Container3D from the palette, made it big enough, Pasted the objects back in (while Container3D was selected) and resized the container holding CTRL key to make sure it does not resize the objects. Then I compiled the projects and confirmed all was working.
Notice that I did NOT have to checkout any files!
So when happy with the changes, switch back to Git Gui (Alt+Tab if you leave it running), and do a Rescan by clicking on the button or F5.
Two files are loaded in the Unstaged Changes. As you select the filename you see the changed lines in the third panel.
In this example we have no interest in committing any changes and basically want to lose all uncommitted changes.
From the menu select Branch-Reset. A warning dialog will indicate that you indeed will lose all uncommitted changes. Select Yes.
Switch back to VDF Studio and notice that the customer view is back to what it was.
Now hold-on you might say, why is this in the branch menu, I would not have looked there... When we look a bit further at branching I promise it will make more sense. If impatience; the short answer is that the master is also a branch.
== Creating a branch and making changes ==
As a developer you should not create changes direct in the master branch. Instead you should create a branch specific to the change you want to make (topic branch), and then when you decide to keep the change, merge the topic branch into the master (or even better in a release branch).
There are two methods of organising the topic branches. The first way is as sibblings, the other way is consecutive. This document starts with the sibbling way.
Let’s create a new branch; switch back to Git gui and select menu: branch – create to open the following dialog;
[[File:UsingGitforVdfDev_image007.png]]
I’ve entered a branch name. Notice that the dialog does not allow you to insert spaces, so use Mixed case notation. Use a naming that refers to an ID in your change request system so use something like “CR5612_UpdateFontsOnReports “.
Notice that the starting revision is ‘master’ but don’t worry about this too much, otherwise you might think it’s more complex than it is.
So click on Create after you entered the name. The dialog changes and all you are left in is the message above the Unstaged Changes panel showing the current branch.
[[File:UsingGitforVdfDev_image008.png]]
Make some changes like commenting out the Crystal reports to save compile time (Includes and menu’s). And replace in CustomerListWP.rv the ‘arial’ font to ‘Segoe UI’.
Compile the project and see how much better the report looks.
Switch back to Git Gui and do a Rescan.
[[File:UsingGitforVdfDev_image009.png]]
You see the three changed files, and at the right the line old and new line.
Let’s assume that this is all the change you want to do for now.  The work is not fully done, as you want to change the font on all the reports, but need to attend to another change you want in your project.
So you stage and commit these changes into this branch. Click ‘Stage Changed’ button (or Ctrl+I), enter a commit message eg ‘Changed first report and removed crystal reports’. Click ‘Commit’ (or Ctrl+Enter).
The next change you want to make is not related to the above change. So you create a new topic branch. You’ll soon found that for each individual programming request you want to create an own topic branch.
But take care when creating the new branch; you want to create this from the master. So in the create branch dialog (Menu Branch-Create), you want to select the master as the Starting revision local branch;
[[File:UsingGitforVdfDev_image010.png]]
''I use the name ‘Topic branch’. This is not a name used in GIT itself, but it is used in the GIT documentation to refer to a branch created for the purpose of creating, updating or removal of a specific feature.''
[[File:UsingGitforVdfDev_image011.png]] 
Hovering over the branch names shows some information regarding the branch, which for the sake of this document highlighted in a green box.
When you click create, you see that the Current Branch is changed to the newly created one.
[[File:UsingGitforVdfDev_image012.png]] 
As you selected the master to be the starting revision, you will also find that when switching back to the VDF Studio, the state of source code is back to what it was when we committed the master. This might worry you but this is a good thing.
Please confirm that the Crystal reports are back and the font is also back to arial.
''If you made a mistake and did not base the new branch on master, just switch away from the new branch with Branch-Checkout and select master. Then do menu Branch-delete and select the wrongly created branch. Once deleted create the new branch again, but this time based on the master.''
Make a change like adding the Total sales to the Sales Person entry view. In this revision we just calculate on the spot, but we might later add a field for it;
[[File:UsingGitforVdfDev_image013.png]] 
I inserted ‘Use for_all.pkg’ at the top of the SalesP.vw  code and the code below just before the End_object of the oContainer1;
<nowiki>
        // This only works from VDF 17.0 where Refresh is also send to containers
        Procedure Refresh Integer eMode
            Send CalculateTotalSales to oTotalSalesForm
        End_Procedure
        Object oTotalSalesForm is a Form
            Set Size to 13 44
            Set Location to 4 182
            Set Form_Datatype to Mask_Currency_Window
            Set Enabled_State to False
            Set Form_Mask to "$,0."
            Set Label to 'Total sales:'
            Set Label_Col_Offset to 2
            Set Label_Justification_Mode to jMode_Right
           
            Procedure CalculateTotalSales
                Number nTotalSales
                Open OrderHea
                For_All OrderHea by 0
                    Constrain OrderHea Relates to SalesP
                    do
                        Add OrderHea.Order_Total to nTotalSales
                End_For_All
                Set Value to nTotalSales
            End_Procedure
        End_Object
</nowiki>
Switch back to Git Gui and do a rescan (F5). You see that SalesP.vw and probably order.cfg are changed.
If you are happy with the changes, then Stage and commit them.
71

edits