Skip to content

Commit

Permalink
Merge pull request #125 from mattpolzin/support-mainbranch-config-cmd
Browse files Browse the repository at this point in the history
Add ability to set mainBranch config prop via CLI
  • Loading branch information
mattpolzin authored May 31, 2024
2 parents edb92ac + cac61be commit 124a197
Show file tree
Hide file tree
Showing 10 changed files with 361 additions and 269 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ idris2-version = $(shell $(idris2) --version | sed -En 's/Idris 2, version ([^-]
idris2-build = $(shell $(idris2) --version | sed -En 's/Idris 2, version [^-]+(.*)/\1/p')
idris2-minor-version = $(shell echo ${idris2-version} | sed -En 's/0\.(.*)\../\1/p')

kernel = $(shell uname -s)

ifeq ($(kernel),Linux)
ised = sed -i''
else
ised = sed -I ''
endif

.PHONY: all build nix-build install package publish clean version

all: build
Expand Down Expand Up @@ -114,10 +122,10 @@ nix-build:

version:
@(if [[ "${v}" == '' ]]; then echo "please set the 'v' variable."; exit 1; fi)
sed -I '' "s/version = .*/version = ${v}/" ./harmony.ipkg
sed -I '' "s/appVersion = \".*\"/appVersion = \"${v}\"/" ./src/AppVersion.idr
sed -I '' "s/\"version\": \".*\"/\"version\": \"${v}\"/" ./package.json
sed -I '' "s/version = \".*\";/version = \"${v}\";/" ./default.nix
$(ised) "s/version = .*/version = ${v}/" ./harmony.ipkg
$(ised) "s/appVersion = \".*\"/appVersion = \"${v}\"/" ./src/AppVersion.idr
$(ised) "s/\"version\": \".*\"/\"version\": \"${v}\"/" ./package.json
$(ised) "s/version = \".*\";/version = \"${v}\";/" ./default.nix
@npm update
@$(node2nix) -- --composition node2nix.nix # -l # <- can't use -l for lockfile because lockfile version 3 not supported yet.
@$(nix) fmt
Expand Down
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
};

harmonyPkg = buildIdris {
version = "4.1.0";
version = "4.2.0";
ipkgName = "harmony";
src = ./.;

Expand Down
2 changes: 1 addition & 1 deletion harmony.ipkg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package harmony
version = 4.1.0
version = 4.2.0
authors = "Mathew Polzin"
license = "MIT"
brief = "Harmony GitHub collaboration tool"
Expand Down
289 changes: 159 additions & 130 deletions node-packages.nix

Large diffs are not rendered by default.

307 changes: 177 additions & 130 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mattpolzin/harmony",
"version": "4.1.0",
"version": "4.2.0",
"engines": {
"node": ">=18.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/AppVersion.idr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module AppVersion

export
appVersion : String
appVersion = "4.1.0"
appVersion = "4.2.0"

export
printVersion : HasIO io => io ()
Expand Down
2 changes: 2 additions & 0 deletions src/Config.idr
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ propSetter RequestTeams = update parseBool (\b => { requestTeams := b })
propSetter RequestUsers = update parseBool (\b => { requestUsers := b })
propSetter CommentOnRequest = update parseBool (\b => { commentOnRequest := b })
propSetter DefaultRemote = update Just (\s => { defaultRemote := s })
propSetter MainBranch = update Just (\s => { mainBranch := s })
propSetter GithubPAT = update Just (\s => { githubPAT := Just $ hide s })
propSetter AssignTeams = update parseBool (\b => { requestTeams := b })
propSetter AssignUsers = update parseBool (\b => { requestUsers := b })
Expand All @@ -154,6 +155,7 @@ propGetter RequestTeams = show . requestTeams
propGetter RequestUsers = show . requestUsers
propGetter CommentOnRequest = show . commentOnRequest
propGetter DefaultRemote = show . defaultRemote
propGetter MainBranch = show . mainBranch
propGetter GithubPAT = maybe "Not set (will use $GITHUB_PAT environment variable)" show . githubPAT
propGetter AssignTeams = show . requestTeams
propGetter AssignUsers = show . requestUsers
Expand Down
5 changes: 5 additions & 0 deletions src/Data/Config.idr
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ data SettableProp : (name : String) -> (help : String) -> Type where
DefaultRemote : SettableProp
"defaultRemote"
"[string] The name of the default Git remote to use (e.g. 'origin')."
MainBranch : SettableProp
"mainBranch"
"[string] The name of the default Git base branch for new PRs."
GithubPAT : SettableProp
"githubPAT"
"""
Expand Down Expand Up @@ -143,6 +146,7 @@ settablePropNamed : (name : String) -> Maybe (Exists (SettableProp name))
settablePropNamed "requestTeams" = Just $ Evidence _ RequestTeams
settablePropNamed "commentOnRequest" = Just $ Evidence _ CommentOnRequest
settablePropNamed "defaultRemote" = Just $ Evidence _ DefaultRemote
settablePropNamed "mainBranch" = Just $ Evidence _ MainBranch
settablePropNamed "githubPAT" = Just $ Evidence _ GithubPAT
settablePropNamed "requestUsers" = Just $ Evidence _ RequestUsers
settablePropNamed "assignTeams" = Just $ Evidence _ AssignTeams
Expand All @@ -164,6 +168,7 @@ settableProps = [
, (_ ** _ ** RequestUsers)
, (_ ** _ ** CommentOnRequest)
, (_ ** _ ** DefaultRemote)
, (_ ** _ ** MainBranch)
, (_ ** _ ** GithubPAT)
, (_ ** _ ** AssignUsers)
, (_ ** _ ** AssignTeams)
Expand Down
3 changes: 2 additions & 1 deletion test/expected_help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Subcommands:
Get or set the value of a configuration property. Not all properties can
be set and read via this subcommand.
properties: requestTeams, requestUsers, commentOnRequest, defaultRemote,
githubPAT, assignUsers, assignTeams, commentOnAssign
mainBranch, githubPAT, assignUsers, assignTeams,
commentOnAssign
contribute [-c/--checkout] [-<num>] [-i/--ignore {<uri>/<pr-number>}]
Contribute to an open PR. Prints a URL. Prioritizes PRs you are requested
to review but will also return other PRs.
Expand Down

0 comments on commit 124a197

Please sign in to comment.