Skip to content

Instantly share code, notes, and snippets.

View scbedd's full-sized avatar

Scott Beddall scbedd

  • Microsoft
  • Seattle, WA
View GitHub Profile
@scbedd
scbedd / tags_since.x.ps1
Created April 11, 2019 18:01
Want to get a list of tags from a git repo?
Function Tags-Since([String] $datesSince = "2019-04-01") {
git rev-parse --is-inside-work-tree
if($LastExitCode -ne 0)
{
Write-Host "Please invoke this function from within a git repository folder. Exiting."
exit(1)
}
@scbedd
scbedd / helpful_regex.md
Created April 11, 2019 22:52
Helpful Regex

Match a release note

(?<releaseNote>\#\s(?<releaseDate>[\-0-9]+)\s-\s(?<version>(\d+)(\.(\d+))?(\.(\d+))?(([^0-9][^\s]+)))(?<releaseText>((?!\s# )[\s\S])*))

Where the form this matches is

# <random text> <version specifier>
<release note content
@scbedd
scbedd / interrogate_active_prs.ps1
Created May 16, 2019 07:11
A little script to get all active PRS from a github repo. Filter by a label if you wish.
# A little script to get all active PRS from a github repo. Filter by a label if you wish.
#
#
# EXAMPLE USAGE
#
# ./interrogate_active_prs.ps1 -labelFilter Dev -gh_token <YOUR GITHUB PAT> -repoName release-testing -repoOwner scbedd
#
# or copy this script locally, set the default repo and owner, set and environment variable of name GH_TOKEN with your PAT, and
# run it simply with a labelfilter if you want.
param (
@scbedd
scbedd / create_venv.ps1
Last active June 10, 2019 21:36
Boilerplate PShell script that will clean and recreate a virtual environment in the local directory under a foldername of your choosing
Function Create-Virtual-Environment([String] $envName = "venv") {
$cwd = Get-Location
$relativePath = Join-Path -Path $cwd -ChildPath $envName
$pathToDeactivate = Join-Path -Path $relativePath -ChildPath "Scripts/deactivate.bat"
# if it already exists make certain to deactivate it
if(Test-Path $pathToDeactivate -PathType Leaf)
{
& $pathToDeactivate
@scbedd
scbedd / get_prs_with_readme.ps1
Last active June 11, 2019 18:15
A little script to get active PRs that affect a readme
# A little script to get active PRs that affect a readme
#
# There are limitations here. Note that pulling the files list associated with a PR does have a maximum. I wouldn't trust this scripts
# to properly assess PRs that have more than 300 files modified.
#
# To get a GITHUB Token: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line
#
# EXAMPLE USAGE (from powershell)
#
# ./get_prs_with_readme.ps1 -labelFilter Dev -gh_token <YOUR GITHUB PAT> -repoName release-testing -repoOwner scbedd
@scbedd
scbedd / transition-versioning-strategy.ps1
Last active March 20, 2020 00:11
Powershell Github.io Versioning v1 -> v2 Transition Script
# transition old style versioning strategy to new. inclusive of existing versions in both strategies
param (
$AzCopy,
$SASKey,
$Language,
$BlobName,
$DocLocation,
$AccountKey
)
@scbedd
scbedd / transition-versioning-js.ps1
Created March 20, 2020 00:12
Updates js files in place so that the previously deployed sites can access the new versioning strategy
# transition old style versioning strategy to new. inclusive of existing versions in both strategies
param (
$AzCopy,
$SASKey,
$Language,
$BlobName,
$DocLocation,
$AccountKey
)
$AccountName = ($BlobName.Replace("https://", "") -Split "\.")[0]
@scbedd
scbedd / copy-readmes-to-docs
Last active April 10, 2020 19:21
Copy Readmes To Docs
# Example Usage: ./copy_readmes.ps1 -CodeRepo C:/repo/sdk-for-python -DocRepo C:/repo/azure-docs-sdk-python
# Highly recommended that you use Powershell Core.
# git reset --hard origin/smoke-test on the doc repo prior to running this
param (
[String]$CodeRepo,
[String]$DocRepo,
[String]$TargetServices = "keyvault,storage"
)
@scbedd
scbedd / get_updated_readmes.py
Last active June 25, 2020 22:23
Given a list of tags, generate relative link replacements from an azure repo
import os
import glob
from subprocess import check_call, CalledProcessError
import pdb
import logging
import sys
import shutil
import requests
from io import StringIO
import csv
@scbedd
scbedd / are_these_folks_part_of_this_org.ps1
Created August 13, 2020 22:33
Check GH Org Membership
$users = "<comma separated list of github users>"
# notice that we substring(1). This is because if you grab the gh users from a codeowners file, there will be a leading @
# the substring rips it off.
$filtered_users = $users.Split(",") | % {$_.Trim()} | ? { $_ } | % { $_.SubString(1) } | Select -Unique
$not_added = @()
$headers = @{
"Content-Type" = "application/json"
"Authorization" = "token $($env:GH_TOKEN)"