Skip to main content

Git repository: merging several PRs into one

Background

In out repository (https://github.com/elhub/im-emif-files ) we create PR (pull request) for each upcoming change.

Since merging those PRs takes some months time (due to legislation and time given to the market to test and come with evental feedbacks), very often we have more than one PR active.

Use-case

Sometimes some market actors would like to combine several PRs into one for testing purposes.
We can combine any combination of available PRs, or take all of them, depending on our needs.

Merging PRs into local branch - example

pr_m_1.png

pr-01.png

In this example we can see 3 branches related to 3 parallel PRs, all taken from the same point in time in main branch.

We want to merge all 3 of them in separate local branch to be able to test the whole set of changes.

We will do this through git client commands.

Presumption here is some basic knowledge of git, having git client, and having git repository cloned and up2date.

Steps

Creating local branch

We will create local branch “localev” based on main branch.

CODE
$ git checkout -b localdev main

Making sure we have latest changes from remote repository

We also want to make sure we have latest changes from remote repository:

CODE
$ git fetch origin

Identifying braches

Let’s loook at all branches in this repository:

CODE
$ git branch
  EI-1250
  EI-270
  README
  WOW-1063
  initial
* localdev
  main

We can also see that we are curently in “localdev” branch.

In graphic mode:

pr-02.png

We can also see that localdev branch is taken from main branch and includes no changes from other branches.

Merging changes in local branch

We identified 3 branches we want to merge changes from into our “localdev” branch:

  • EI-1250 (PR1)

  • EI-270 (PR2)

  • WOW-1063 (PR3)

We run following commands:

CODE
$ git merge origin/EI-1250
Merge made by the 'ort' strategy.
 bim/common/Elhub_BusinessDataType.xsd | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
$ git merge origin/EI-270
Merge made by the 'ort' strategy.
 bim/common/Elhub_AggregatedBusinessInformationEntities.xsd | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
$ git merge origin/WOW-1063
Auto-merging bim/common/Elhub_AggregatedBusinessInformationEntities.xsd
Merge made by the 'ort' strategy.
 bim/common/Elhub_AggregatedBusinessInformationEntities.xsd | 1 +
 1 file changed, 1 insertion(+)

 

Now we can see that localdev branch includes changes from all of those 3 branches and is based on main branch.

pr-03.png

Running diff

We can easily run git diff against main branch and identify all changes;

CODE
$ git diff localdev origin/main

 

Result, in our example:

CODE
diff --git a/bim/common/Elhub_AggregatedBusinessInformationEntities.xsd b/bim/common/Elhub_AggregatedBusinessInformationEntities.xsd
index 98cec6c..ae0a263 100644
--- a/bim/common/Elhub_AggregatedBusinessInformationEntities.xsd
+++ b/bim/common/Elhub_AggregatedBusinessInformationEntities.xsd
@@ -25,7 +25,7 @@
                        <xsd:choice minOccurs="1" maxOccurs="1">
                                <xsd:element name="Observation" type="abie:QuantityMeteredCollect" minOccurs="1" maxOccurs="9999"/>
                                <xsd:element name="ProfiledObservation" type="abie:QuantityProfiledCollect" minOccurs="1" maxOccurs="1"/>
-                               <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeType" minOccurs="1" maxOccurs="2"/>
+                               <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeType" minOccurs="1" maxOccurs="1"/>
                        </xsd:choice>
                </xsd:sequence>
        </xsd:complexType>
@@ -150,13 +150,11 @@
                <xsd:sequence>
                        <xsd:element name="Total" type="bdt:long12" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="CalculationMethod" type="bdt:CalculationMethod" minOccurs="1" maxOccurs="1"/>
-                       <xsd:element name="Direction" type="bdt:DirectionType" minOccurs="0" maxOccurs="1"/>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:complexType name="Elhub_EstimatedAnnualVolumeType">
                <xsd:sequence>
                        <xsd:element name="Total" type="bdt:long12" minOccurs="1" maxOccurs="1"/>
-                       <xsd:element name="Direction" type="bdt:DirectionType" minOccurs="0" maxOccurs="1"/>
                </xsd:sequence>
        </xsd:complexType>
        <xsd:complexType name="Elhub_HeaderType">
@@ -326,7 +324,7 @@
                        <xsd:element name="ConsumerInvolvedCustomerParty" type="abie:Elhub_CustomerPartyNotifyType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeteringGridAreaUsedDomainLocation" type="abie:Elhub_MeteringGridAreaType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MpDetailMeteringPointCharacteristic" type="abie:Elhub_DetailMeteringPointCharacteristicType" minOccurs="0" maxOccurs="1"/>
-                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeDetailType" minOccurs="0" maxOccurs="2"/>
+                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeDetailType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeteringInstallationMeterFacility" type="abie:Elhub_MeterFacilityType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MPTaxationProfile" type="abie:Elhub_TaxationProfileMeteringPointType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeasurementDefinition" type="abie:Elhub_MeasurementDefinitionType" minOccurs="0" maxOccurs="99"/>
@@ -353,7 +351,7 @@
                        <xsd:element name="ConsumerInvolvedCustomerParty" type="abie:Elhub_CustomerPartyStartOfSupplyType" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="ConsumerInvolvedCustomerAddress" type="abie:Elhub_InvoiceeAddressType" minOccurs="1" maxOccurs="2"/>
                        <xsd:element name="MPDetailMeteringPointCharacteristics" type="abie:Elhub_DetailMeteringPointCharacteristicType" minOccurs="0" maxOccurs="1"/>
-                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeDetailType" minOccurs="0" maxOccurs="2"/>
+                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeDetailType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeteringInstallationMeterFacility" type="abie:Elhub_MeterFacilityType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MPTaxationProfile" type="abie:Elhub_TaxationProfileMeteringPointType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeasurementDefinition" type="abie:Elhub_MeasurementDefinitionType" minOccurs="0" maxOccurs="99"/>
@@ -494,7 +492,6 @@
                        <xsd:element name="MeteringPointUsedDomainLocation" type="abie:Elhub_MeteringPointType" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="BalanceSupplierInvolvedEnergyParty" type="abie:Elhub_EnergyPartyType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="moveInToSLR" type="bdt:Elhub_boolean" minOccurs="0" maxOccurs="1"/>
-                       <xsd:element name="ConsentID" type="bdt:UUIDType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="ConsumerInvolvedCustomerParty" type="abie:Elhub_CustomerPartyStartOfSupplyType" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="ConsumerInvolvedCustomerAddress" type="abie:Elhub_InvoiceeAddressType" minOccurs="1" maxOccurs="2"/>
                </xsd:sequence>
@@ -535,7 +532,7 @@
                        <xsd:element name="MPPositionMeteringPointGeographicalCoordinate" type="abie:Elhub_MeteringPointGeographicalCoordinateType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MPAddressCadastral" type="abie:Elhub_MPAddressCadastralType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MpDetailMeteringPointCharacteristic" type="abie:Elhub_DetailMeteringPointCharacteristicType" minOccurs="0" maxOccurs="1"/>
-                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeDetailType" minOccurs="0" maxOccurs="2"/>
+                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeDetailType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeteringInstallationMeterFacility" type="abie:Elhub_MeterFacilityType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MPTaxationProfile" type="abie:Elhub_TaxationProfileMeteringPointType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MeasurementDefinition" type="abie:Elhub_MeasurementDefinitionGenericType" minOccurs="0" maxOccurs="99"/>
@@ -591,7 +588,7 @@
                        <xsd:element name="MeteringGridAreaUsedDomainLocation" type="abie:Elhub_MeteringGridAreaType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MpDetailMeteringPointCharacteristic" type="abie:Elhub_DetailMeteringPointCharacteristicType" minOccurs="1" maxOccurs="1"/>
                        <xsd:element name="MeteringInstallationMeterFacility" type="abie:Elhub_MeterFacilityType" minOccurs="0" maxOccurs="1"/>
-                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeType" minOccurs="0" maxOccurs="2"/>
+                       <xsd:element name="AnnualPeriodEstimatedMetrics" type="abie:Elhub_EstimatedAnnualVolumeType" minOccurs="0" maxOccurs="1"/>
                        <xsd:element name="MPTaxationProfile" type="abie:Elhub_NACEConsType" minOccurs="0" maxOccurs="1"/>
                </xsd:sequence>
        </xsd:complexType>
diff --git a/bim/common/Elhub_BusinessDataType.xsd b/bim/common/Elhub_BusinessDataType.xsd
index 015f5f0..abc1fee 100644
--- a/bim/common/Elhub_BusinessDataType.xsd
+++ b/bim/common/Elhub_BusinessDataType.xsd
@@ -153,7 +153,6 @@
                        <xsd:enumeration value="A04"/>
                        <xsd:enumeration value="A07"/>
                        <xsd:enumeration value="A15"/>
-                       <xsd:enumeration value="B25"/>
                        <xsd:enumeration value="B27"/>
                </xsd:restriction>
        </xsd:simpleType>
@@ -938,27 +937,9 @@
        </xsd:simpleType>
        <xsd:simpleType name="ProductionCode">
                <xsd:restriction base="xsd:string">
-                       <xsd:enumeration value="B01"/>
-                       <xsd:enumeration value="B02"/>
-                       <xsd:enumeration value="B03"/>
-                       <xsd:enumeration value="B04"/>
-                       <xsd:enumeration value="B05"/>
-                       <xsd:enumeration value="B06"/>
-                       <xsd:enumeration value="B07"/>
-                       <xsd:enumeration value="B08"/>
-                       <xsd:enumeration value="B09"/>
-                       <xsd:enumeration value="B10"/>
-                       <xsd:enumeration value="B11"/>
-                       <xsd:enumeration value="B12"/>
-                       <xsd:enumeration value="B13"/>
                        <xsd:enumeration value="B14"/>
-                       <xsd:enumeration value="B15"/>
                        <xsd:enumeration value="B16"/>
-                       <xsd:enumeration value="B17"/>
-                       <xsd:enumeration value="B18"/>
-                       <xsd:enumeration value="B19"/>
                        <xsd:enumeration value="B20"/>
-                       <xsd:enumeration value="B25"/>
                        <xsd:enumeration value="Z04"/>
                        <xsd:enumeration value="Z05"/>
                        <xsd:enumeration value="Z06"/>

At this point we have all 3 PRs merged into single local branch. for further analasys and testing, a shown in diagram below (LD3)

pr_m_2.png

Important: only Elhub has read/write access to remote repository. Therefore, this local branch can’t be pushed to remote repository.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.