Package: gitinsights
Git-based SCM Insights SDKGit-based SCM Insights SDKOverviewSupported Source Code Management ProvidersADO Insight CapabilitiesReportable FieldsInstallationOption 1 - Install with pipOption 2 - Deploy to Azure with TerraformOption 3 - Setup local Azure Function environmentAzure Function PrerequisitesStepsSDK UsageExampleBacklog Features - will be migrated to repo backlogContributinggit-insightsis awork in progress / early daystoolset enabling engineering leads to gain insights around how a team is collaborating towards a project's workitems and codebase. Devs can use this sdk to identify opportunities to collectively help other team members improve collaboration.git-insightsconnects to your existing source code management repositories and work item activities to provide insights toward active and completed scheduled work, git commits, pull requests and code reviews. The dataset can also be used to collectively celebrate progress week over week.OverviewSupported Source Code Management ProvidersAzure Dev OPSGitLab (coming soon)GitHub (coming soon)ADO Insight CapabilitiesActive / completed workitems (incl duration averages)Workitem creationPushed commitsGit commit log stats (ie sum of line edits, additions, deletions)Active / completed story pointsActive / completed pull requests (incl duration averages)Code review comments + reviewsAzure Function integration to support report scheduling and deliveryReportable FieldsSample DatasetField NameDescriptionTypecontributorThe profile display name of the activity contributor / assigneeStringweekThe week of year for the captured activityintrepoThe git repository nameStringprs_mergedSum of pull requests merged into themainbranchintprs_submittedSum of pull requests submitted for reviewintpr_completion_daysMean Average duration for pull request review (ie days diff between PR submission date and completion date)floatpr_commentsSum of posted pull request review commentsintprs_reviewedSum of submitted pull requests reviewedintpr_commits_pushedSum of git commits pushed to active pull requestsintcommit_change_count_editsSum of changed lines within the commit logintcommit_change_count_deletesSum of removed lines within the commit logintcommit_change_count_additionsSum of newly added lines within the commit logintuser_stories_assignedSum of user stories assigned to the contributorintuser_stories_completedSum of user stories completed or resolved by the contributorintuser_story_points_assignedSum of story points asssigned to the contributorintuser_story_points_completedSum of completed story pointsintuser_story_completion_daysMean Average duration for user story completion (ie days diff between story assignment and completion date)floatuser_stories_createdSum of user stories createdintuser_story_initial_pr_submission_daysMean average of elapsed time between the datetime of a user story activated date and the initial pull request submission date.floatInstallationThis SDK can be used either through the pip package or as an Azure Function.PrerequisitesAn Azure SubscriptionAnADO PAT Tokenwith read permissions scoped to Code, Work Items and Graph.An ADO organization, project, repo(s) and a backlog teamAll project dependencies such as Python, Azure Functions CLI and Terraform are configured as an easy to consumeDevelopment Container. To use this, install theRemote Development Extensionand then followthese instructionsfor opening the workspace in the containerized environment.Option 1 - Install with pippip install gitinsightsOption 2 - Deploy to Azure with TerraformThis application can be easily deployed to Azure using Terraform by following theTerraform Getting Started GuideOption 3 - Setup local Azure Function environmentAzure Function PrerequisitesVSCodeAzure Blob Storage AccountKeyvault ResourceAsecretcontaining the value of your PAT token.Service Principalwith read level role assignments into the above Keyvault resourceStepsClone the repogit clone https://github.com/erikschlegel/git-insights.git
cd git-insights
pip install -r requirements.txt && pip install -r requirements-dev.txtOnce the Azure extension is installed, sign into your Azure account by navigating to the Azure explorer, select Sign in to Azure under Functions, and follow the prompts in the browser.After signing in, verify that the status bar says Azure: Signed In and your subscription(s) appears in the Azure explorer:To verify that all the Azure Functions tools are installed, open the Visual Studio Code Command Palette (F1), select the Terminal: Create New Integrated Terminal command, and once the terminal opens, run the commandfuncConfiguration SetupRenamelocal.settings.json.template->local.settings.jsonProvide the Azure storage account's primary connection string for both thegitinsights_STORAGEandAzureWebJobsStoragesettings.Provide the service principal credentials for the following settings:AZURE_CLIENT_SECRET,AZURE_TENANT_ID,AZURE_CLIENT_ID,AZURE_SUBSCRIPTION_IDProvide the keyvault name for theKeyvaultNamesetting, and the secret containing the PAT token for thePatSecretNamesettingProvide the ADO organization name, project name, repositories (comma delimited for multiple) and backlogteam name.Set a breakpoint in the code and hit F5 to debug locally.The function will write the results to your blob storage account prior to completion.JFYI: This particular Azure Function is scheduled to run every friday at 9AM. Editfunctions.jsonif you'd like to change theNCRONTAB schedule.SDK UsageExamplefromgitinsights.mods.managers.adoimportAzureDevopsClientManageradoProject="Seinfeld-Trivia"adoOrg="Best-Shows"repos=["a-repo-about-nothing"]teamId="Team LD"patToken="Kramers-secret"groupByColumns=['contributor','week','repo']client=AzureDevopsClientManager(adoOrg,adoProject,repos,teamId,patToken)dataframe=client.aggregatePullRequestActivity(groupByColumns)print(dataframe)Backlog Features - will be migrated to repo backlogAzure Functions IntegrationDockerize Azure FunctionAdd Azure Function Continuous Delivery PipelineIntegrate with PowerBITerraform integration to automate scaffolding of keyvault, azure function and blob storage resourcesAdd E2E Integration TestsAdd pre-commit hook to block pushes including credsAdd a new provider to support Git Lab integrationIntegrateSphinxto autogen SDK docsContributing============You can contribute to the project in multiple ways:Write documentationImplement featuresFix bugsAdd unit and functional testsEverything else you can think of