Forum Discussion
bwhitlock
Helper II
5 years agoKeep track of changes
HI all Looking for an environment to track my changes Im doing in Power bi or power apps. Any recommendations. May not be able to track in power bi itself, but looking for a way record or note chang...
lbendlin
Super User
5 years agoSince there is no official Github support yet I use the following process
- created my own github repository
- whenever I make substantial design changes I export as .pbit
- then I run a powershell script to read the .pbit (it's a ZIP file) and to rename a few of the files inside it to something usable
- the resulting files are stored in the local git repository clone, ready to be synced to the repository.
Here's some sample Powershell code.
# Alias for 7-zip
if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"}
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
# set location
Set-Location -Path C:\Users\yyy\Documents\GitHub\xxx
# get .pbit files
$files = Get-ChildItem -Recurse -Include *.pbit | Select Name,FullName,LastWriteTime
for ($i = 0; $i -lt $files.Count; $i++) {
if($files[$i].LastWriteTime -gt (Get-Date).AddDays(-2)) {
Write-Host $files[$i].Name
$p = $files[$i].FullName
$e = $p.LastIndexOf(".")
#target folder
$d = $p.Substring(0,$e)
#Write-Host $d
# remove entire folder, so we don't have to care about removing individual items
Remove-Item -LiteralPath $d -Recurse -Force
# 7Zip doesn't need the renaming
sz x "$p" -o"$d" -aoa | Out-Null
Rename-Item -LiteralPath ($d + "\Report\Layout") -NewName "Layout.json" -Force -ErrorAction Ignore
Rename-Item -LiteralPath ($d + "\Connections") -NewName "Connections.json" -Force -ErrorAction Ignore
Rename-Item -LiteralPath ($d + "\DiagramLayout") -NewName "DiagramLayout.json" -Force -ErrorAction Ignore
Rename-Item -LiteralPath ($d + "\DiagramState") -NewName "DiagramState.json" -Force -ErrorAction Ignore
#extract DataMashup
#sz x "$d\DataMashup" -o"$d\Mashup" -aoa | Out-Null
#clean up DataModelSchema
$DMS = Get-Content -Raw -Path ($d + "\DataModelSchema") -Encoding Unicode | ConvertFrom-Json
#new meta format doesn't have datasources. Now $DMS.model.tables
if($DMS.compatibilityLevel -lt 1520) {
$DMS.model.dataSources | ForEach-Object -Process {
#find mashup part of connectionString
$c1 = $_.connectionString.IndexOf("Mashup=", [StringComparison]"CurrentCultureIgnoreCase")
#no mashup for direct query
if( $c1 -gt 1 ) {
$c2 = $_.connectionString.LastIndexOf("Location=", [StringComparison]"CurrentCultureIgnoreCase")
$m = $_.connectionString.Substring($c1 + 7,$c2-$c1-8)
#remove quotes if needed
$m = $m -replace '"',""
#$m.Length
$_.connectionString = $_.connectionString.Substring(0,$c1 + 7) + "..." + $_.connectionString.Substring($c2-1,$_.connectionString.Length - $c2 +1)
#$_.name
# write connection zip file - Base64 encoded mashup string
#$bytes = [Convert]::FromBase64String($m)
#[IO.File]::WriteAllBytes($d + "\" + $_.name + ".zip", $bytes)
}
}
}
# write corrected Json
$DMS | ConvertTo-Json -Depth 3 | Add-Content -LiteralPath ($d + "\DataModelSchema.json")
}
}