Compare commits

...

187 Commits

Author SHA1 Message Date
Jeff Carr cfc91c8ba6 rm GOSRC 2025-09-11 23:10:38 -05:00
Jeff Carr 1c8f502c1b rm old code 2025-09-11 06:31:38 -05:00
Jeff Carr a72e9ce5f4 NEVER LEAVE JUNK IN GO REPOS EVER 2025-02-22 19:11:51 -06:00
Jeff Carr 3ab156a9c4 gitpb code is changing 2025-02-21 09:33:58 -06:00
Jeff Carr fa5c6572ff should help race conditions 2025-01-30 18:00:03 -06:00
Jeff Carr d568d5dbe4 make the buttons work 2025-01-30 13:44:22 -06:00
Jeff Carr 4484b0b84d new window for merge on a single repo 2025-01-30 13:35:22 -06:00
Jeff Carr c079039ffe func name change 2025-01-30 11:50:23 -06:00
Jeff Carr ff91deee63 func name change 2025-01-30 11:27:37 -06:00
Jeff Carr 2395a4466e delete old code. start refactor to protobuf 2025-01-29 16:18:32 -06:00
Jeff Carr 2b2de94eff old code 2025-01-29 12:26:00 -06:00
Jeff Carr 750ceaf8a1 old status vestages of the past are gone 2025-01-19 07:06:03 -06:00
Jeff Carr ac2958e559 code now moved to gitpb 2025-01-18 15:48:52 -06:00
Jeff Carr a15d447fbd more removal of old code 2025-01-07 22:28:50 -06:00
Jeff Carr fcb74ce2e8 attempt to set pb.State 2025-01-07 20:39:30 -06:00
Jeff Carr 648d3ac6b6 blah 2025-01-07 19:43:01 -06:00
Jeff Carr f53f1256f1 more rm old code 2025-01-07 19:29:46 -06:00
Jeff Carr 4efbead37c last of the easy rm old code 2025-01-07 19:09:25 -06:00
Jeff Carr 4dcd9a1164 mv code. eventually move to shell 2025-01-07 18:53:58 -06:00
Jeff Carr d9a54a6c31 still rm old code 2025-01-07 18:45:34 -06:00
Jeff Carr 9221f83aaf rm old code 2025-01-07 18:29:31 -06:00
Jeff Carr e323d5920c rm old code 2025-01-07 18:24:17 -06:00
Jeff Carr 07e0fdc437 rm old code 2025-01-07 18:18:38 -06:00
Jeff Carr 669c4e082c try to debug gui stuff 2025-01-07 05:59:12 -06:00
Jeff Carr 904a5e8568 remove lots of old stuff! 2025-01-07 04:58:05 -06:00
Jeff Carr 2ea1113c72 ignore 'gui' in .git/config 2025-01-07 03:24:05 -06:00
Jeff Carr 05d827868e move merge code to gitpb 2025-01-05 12:01:39 -06:00
Jeff Carr 3a53e0bd9b more things moved to gitpb 2024-12-17 18:49:24 -06:00
Jeff Carr 93e9e4e43b changes in gitpb 2024-12-17 06:36:45 -06:00
Jeff Carr 54cdb3fbec rm old code 2024-12-03 18:03:29 -06:00
Jeff Carr 283bd90e91 lots more moved to using the protobuf 2024-12-03 00:34:55 -06:00
Jeff Carr d5c394d3c3 moving things to protobuf 2024-11-30 02:03:17 -06:00
Jeff Carr b52c3c426a start moving things to gitpb 2024-11-29 23:18:46 -06:00
Jeff Carr c25e4dd406 hardcode go1.20 and above for testing mac builds 2024-11-29 22:46:02 -06:00
Jeff Carr e43863e8e7 start refactor to protobuf 2024-11-28 18:36:29 -06:00
Jeff Carr 9d13c972e4 always use https for git clone 2024-11-24 23:35:36 -06:00
Jeff Carr 2866815e3c work towards a global override file 2024-11-22 22:30:08 -06:00
Jeff Carr 4c46927bc7 todo: get this from 'go list' somehow? 2024-11-22 20:48:02 -06:00
Jeff Carr a1ce58e9d0 git clone needs to enforce downloading into godir/ 2024-11-17 17:19:09 -06:00
Jeff Carr 94e98f2145 fix clone logic 2024-11-17 16:07:39 -06:00
Jeff Carr 9358005c9d rework Clone() 2024-11-17 14:42:49 -06:00
Jeff Carr 2e8a1d4793 use more realtime output for git clone 2024-11-15 09:12:47 -06:00
Jeff Carr 4ab00cce02 minor rm 2024-11-14 21:48:21 -06:00
Jeff Carr a7c5499221 quiet some output 2024-11-13 11:56:02 -06:00
Jeff Carr 009d8f3b9d improve output handling via go-cmd
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-13 10:33:25 -06:00
Jeff Carr 55acea0bd7 use go-cmd/cmd 2024-11-08 06:43:33 -06:00
Jeff Carr 29545d3f04 clearer debugging 2024-11-07 07:04:39 -06:00
Jeff Carr 5be028858c start moving mappings to a config file 2024-11-07 05:08:17 -06:00
Jeff Carr 6b1330d7f3 remove old stdout junk 2024-11-07 02:25:31 -06:00
Jeff Carr 3ce9f5f773 find .proto and .pb.go files
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 20:30:00 -06:00
Jeff Carr 44ab5deb3f more work on protobuf files
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 19:23:05 -06:00
Jeff Carr 31355467a5 dumb nil panic
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-06 15:51:29 -06:00
Jeff Carr e6f883a9b5 final commits before release
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-05 05:58:54 -06:00
Jeff Carr 8eb7501855 add repo.Whitelist bool
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-05 03:14:46 -06:00
Jeff Carr 8786690d46 init flag for new repos
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-04 02:16:19 -06:00
Jeff Carr b451591006 DirtyList()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-01 21:41:16 -05:00
Jeff Carr bf2a42ec64 hack to override golang.org/x URL's
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-10-11 21:14:46 -05:00
Jeff Carr 5bc1a24a69 use 'go list' to get the URL 2024-03-21 19:43:52 -05:00
Jeff Carr 2ce9051921 exec things to STDOUT
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-03-21 16:16:35 -05:00
Jeff Carr 804acc169a fix logic for go.work setups 2024-03-09 22:03:18 -06:00
Jeff Carr 2622e90b1f one must pass the go path to go mod init 2024-03-09 18:30:04 -06:00
Jeff Carr 7d3e4ce84e add submodules section of the .git/config 2024-03-09 16:50:18 -06:00
Jeff Carr 546ad6a842 look for go-import in the HTML 2024-03-08 15:09:46 -06:00
Jeff Carr 54367ddc72 initial clone works 2024-03-07 22:08:32 -06:00
Jeff Carr 2cdf2c3cda working on go-clone 2024-03-07 19:31:52 -06:00
Jeff Carr f99dc30b68 quiet logging 2024-03-02 22:28:55 -06:00
Jeff Carr 65a94faa57 increment versions 2024-03-02 20:47:36 -06:00
Jeff Carr 412c84fcd9 generate valid DebianVersions() 2024-03-02 17:52:45 -06:00
Jeff Carr b2d3d13ed9 get the proper devel branch name 2024-03-02 13:35:43 -06:00
Jeff Carr b12bc0a9ec export isGitDir() 2024-03-01 21:45:06 -06:00
Jeff Carr 4d2f68606e remove bad function name 2024-02-29 21:57:56 -06:00
Jeff Carr 035b4eb443 quiet git pull 2024-02-29 19:16:45 -06:00
Jeff Carr fc849f6003 add the concept of "mode" for the git repos 2024-02-25 13:10:44 -06:00
Jeff Carr 9a1347c03f add git fetch 2024-02-25 09:42:54 -06:00
Jeff Carr b354d7dd27 try to show actual changes 2024-02-24 11:56:02 -06:00
Jeff Carr cec5e7f3b4 cleanup checkdirty code
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-24 05:37:53 -06:00
Jeff Carr ccee573364 report dirty state change
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-24 05:27:58 -06:00
Jeff Carr ddd95e9afc GitPull() detects local only branches 2024-02-24 04:50:31 -06:00
Jeff Carr 2a62d23482 fix missing append 'v' 2024-02-23 12:47:05 -06:00
Jeff Carr 28a20e0922 add repo.IsPrivate() 2024-02-23 11:00:33 -06:00
Jeff Carr 5268267408 expose the computed autoincrement value 2024-02-23 07:28:15 -06:00
Jeff Carr 1b65474a69 add LastTag() 2024-02-23 01:23:29 -06:00
Jeff Carr 5105bd4a99 add repo.IncrementVersion() 2024-02-23 00:10:30 -06:00
Jeff Carr 359ebce26e mtime 2024-02-22 17:19:29 -06:00
Jeff Carr cd5f1d9d0f add NewestTag() and Tag.Age() 2024-02-22 15:29:22 -06:00
Jeff Carr 5aaf02ee3a actually create the user branches 2024-02-22 05:24:31 -06:00
Jeff Carr 70e8c98b1c go primative logic is correct now 2024-02-20 18:56:22 -06:00
Jeff Carr 2a19cd5eef finally rename back to 'Update' 2024-02-20 14:45:43 -06:00
Jeff Carr e1e81ab2bf fix log output 2024-02-20 11:00:06 -06:00
Jeff Carr d16cc92286 first pass at cleaning up the go.* logic 2024-02-20 06:54:11 -06:00
Jeff Carr ae7e9ba42c allow more fields to be mirrored 2024-02-19 16:29:10 -06:00
Jeff Carr ad21d5d5db experiment with widget 'mirror' 2024-02-19 14:42:59 -06:00
Jeff Carr be73f6af0e deprecate 2024-02-18 17:57:12 -06:00
Jeff Carr 1bafc298d3 guireleaser runs again 2024-02-18 15:09:48 -06:00
Jeff Carr 6a6ebf78b8 return the error 2024-02-18 07:25:48 -06:00
Jeff Carr 4d1301288e export Status 2024-02-17 15:49:12 -06:00
Jeff Carr 0e26f2024a changes for repolist package 2024-02-17 08:39:09 -06:00
Jeff Carr 45519f2370 drat
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-16 21:41:15 -06:00
Jeff Carr 6e7759f570 almost to a release 2024-02-16 21:28:22 -06:00
Jeff Carr f82743d487 redo the merge code 2024-02-16 21:20:52 -06:00
Jeff Carr c7aaea4ae1 continue to redo the branch handling 2024-02-16 20:36:31 -06:00
Jeff Carr 0b4f4d7686 ready to work on creating branches 2024-02-16 17:55:13 -06:00
Jeff Carr bd62a89a67 continue cleaning up original version 2024-02-16 11:41:29 -06:00
Jeff Carr 88ca40bcfa tag date format things 2024-02-16 01:22:37 -06:00
Jeff Carr 2bc2096e84 xterm fixes
also a i18n syntax idea
   show all tags in the main window
2024-02-15 22:50:50 -06:00
Jeff Carr e6eb92845a add a lookup by path function 2024-02-14 15:18:39 -06:00
Jeff Carr 3d6002b055 need correct logic here to read main branch name
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 13:48:46 -06:00
Jeff Carr 73d711ad2b trying to improve older code
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 02:35:47 -06:00
Jeff Carr d7e391fed0 force reverted a branch
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 01:01:00 -06:00
Jeff Carr a223e9f1c3 more code reorg
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 00:26:58 -06:00
Jeff Carr 07a60ffe3c code reorg
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 00:19:36 -06:00
Jeff Carr f7947b08b6 code reorg and clean
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-14 00:09:58 -06:00
Jeff Carr 95fd6ca05a check go.wit.com is mapping a repo 2024-02-13 16:17:29 -06:00
Jeff Carr d7a0246af9 add more xterm options 2024-02-12 21:50:54 -06:00
Jeff Carr e7a3ef1298 try to probe the git go package type
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-12 18:16:03 -06:00
Jeff Carr b4a571fb70 add option to spawn xterm. used for this commit 2024-02-12 15:27:40 -06:00
Jeff Carr ba4051cb0c smarter tag window
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-12 06:23:31 -06:00
Jeff Carr 2b172338f6 don't track hidden in here
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-11 18:56:55 -06:00
Jeff Carr b694fc2fe2 add CheckoutDevel()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-10 16:32:39 -06:00
Jeff Carr 35e03959ab bad logic on 'first' tag
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-09 04:55:08 -06:00
Jeff Carr 49724b16e8 more on tags
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-07 08:51:45 -06:00
Jeff Carr 678d6357b1 generate go.work file for pkgsite
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-06 04:02:46 -06:00
Jeff Carr 309cf80e16 `git ls-files`
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-05 19:01:50 -06:00
Jeff Carr abb1f0ea21 also re-scan .git/config on rs.Update()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-02 16:36:51 -06:00
Jeff Carr 118825e7a3 go.sum checking logic moving to guireleaser app
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-02 01:42:52 -06:00
Jeff Carr 3937902a7d return true/false
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-01 13:30:01 -06:00
Jeff Carr 08b122ea2c release changes
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-31 16:38:31 -06:00
Jeff Carr 4d665387fe more on release management
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-31 04:07:49 -06:00
Jeff Carr dbf10cddf7 Update() the gui releaser
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-31 02:30:14 -06:00
Jeff Carr fae78b1812 allow switching all branches
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-31 00:19:39 -06:00
Jeff Carr 1fda646fef add a stat(file) shortcut
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-30 16:48:57 -06:00
Jeff Carr 78049e664d merge automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-30 13:31:46 -06:00
Jeff Carr 940096ff40 start trimming out release things
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-30 12:11:42 -06:00
Jeff Carr ca09e7cf47 just use and parse 'git status' as it's more accurate
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-30 10:08:07 -06:00
Jeff Carr a05f6c35ce hide things that should be move to the revision app
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-30 01:37:44 -06:00
Jeff Carr 7e7dbebcee testing go
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-29 11:26:43 -06:00
Jeff Carr 408a400e93 testing go
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-29 09:31:22 -06:00
Jeff Carr 856b479edb fullAutomation() checking enabled
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-27 14:39:43 -06:00
Jeff Carr 7bcbca3fce more release version automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-27 13:06:57 -06:00
Jeff Carr e6cb846ccf more on full release automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-27 11:09:08 -06:00
Jeff Carr 318b748509 more on full automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-27 10:52:22 -06:00
Jeff Carr 6d8a49d432 more release automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-27 10:48:56 -06:00
Jeff Carr 386125826f more work on release versioning
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-26 11:53:22 -06:00
Jeff Carr 9147079092 automation improvements
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-26 09:34:13 -06:00
Jeff Carr 2723e53396 working on update order
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-26 02:41:14 -06:00
Jeff Carr 9f26bc2d44 go status moving here
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-26 02:02:56 -06:00
Jeff Carr 2aed84cf3a attempt to ignore missing go.sum requirements
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-25 23:19:51 -06:00
Jeff Carr 45e7aab862 move comments to the cmd output widget
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-25 22:59:49 -06:00
Jeff Carr a80347531e don't clear the tag message
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-25 22:47:42 -06:00
Jeff Carr 86136ce615 avoid a few nil's
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-25 02:23:56 -06:00
Jeff Carr 4beeb0bb13 cleaning code for release versions
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-25 01:30:01 -06:00
Jeff Carr 21546ce2c0 more attempts to release versions
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-24 16:24:58 -06:00
Jeff Carr 732ac4b1e5 further towards release automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-24 02:22:32 -06:00
Jeff Carr 3c3dc5309a release automation
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-24 01:57:01 -06:00
Jeff Carr 7c82f918aa detect go.sum is clean
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-23 22:47:39 -06:00
Jeff Carr edf74e160e still has oneliner display bug
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-23 15:39:53 -06:00
Jeff Carr dae15b5931 Scan() everything functions
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-23 15:20:54 -06:00
Jeff Carr 2f4cba36dd allow user to switch branches
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-23 11:12:58 -06:00
Jeff Carr 294119e7c2 buttons for scanning .git/config and go.sum
common branch handling
    scan go.sum & .git/config on New()
    parse go & git config files
    cleaner debugging
    cleaning up logging

Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-23 10:52:17 -06:00
Jeff Carr 7546209d24 work on making a map of the windows
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-21 03:18:07 -06:00
Jeff Carr 696b58744c new gadgets
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-21 02:18:33 -06:00
Jeff Carr a9a42d5cd8 add 'git pull' button
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-20 21:38:12 -06:00
Jeff Carr ca5007fa87 add git pull
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-20 21:33:28 -06:00
Jeff Carr 7a05ee53ab changes for the autotypist
go mod automation testing
    read tags

    Signed-off-by: Jeff Carr <jcarr@wit.com>

Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-20 21:18:03 -06:00
Jeff Carr e3cc044efc works again
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-19 18:25:37 -06:00
Jeff Carr e7257a919d lots of things broken
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-19 12:36:52 -06:00
Jeff Carr 7a283a1da6 SetText()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-19 12:24:19 -06:00
Jeff Carr 39da8e6810 always cheat with goimport
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-19 01:23:50 -06:00
Jeff Carr d3807e5f13 go mod
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-19 00:04:41 -06:00
Jeff Carr db3d481c5f more git change tracking
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 17:37:50 -06:00
Jeff Carr 8e9e19a14f goimport fix
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 16:20:11 -06:00
Jeff Carr 940b1d8b6e old code, new gadgets
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 15:13:42 -06:00
Jeff Carr 1d2dacab26 strangely time.Sleep() doesn't work
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 14:21:38 -06:00
Jeff Carr e741567fef fix paths
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 05:35:05 -06:00
Jeff Carr 623b35629b new paths
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 05:01:54 -06:00
Jeff Carr ff3a51f354 gofmt autofix paths
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-18 00:57:43 -06:00
Jeff Carr 47a665be8b new go mod
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-17 21:53:03 -06:00
Jeff Carr 2f222b0bd7 compiles, runs, but displays is blank
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-17 03:59:13 -06:00
Jeff Carr cf3d56475d GetPath() & CheckoutBranch()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-16 04:47:44 -06:00
Jeff Carr 78a3adeb15 hard code path again
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-16 00:21:21 -06:00
Jeff Carr c65dd45ba5 better debugging output
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-15 23:41:04 -06:00
Jeff Carr b2c21e8c16 working on CheckDirty()
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-15 22:55:19 -06:00
Jeff Carr 269ff54715 stuff
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-15 17:03:06 -06:00
Jeff Carr ceaab24e56 work on autotypist reset
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-15 08:12:04 -06:00
Jeff Carr ba825e7eb0 Hide() works
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-15 00:17:01 -06:00
Jeff Carr de5f84717f Custom() detects window close
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-14 22:14:02 -06:00
Jeff Carr 784536b18a more safe clicking
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-01-14 15:51:25 -06:00
21 changed files with 1279 additions and 1043 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*.swp
go.mod
go.sum

View File

@ -1,11 +1,15 @@
all:
@echo
@echo Run: make redomod
@echo
@# ./myrepos >/tmp/myrepos.stderr 2>&1
all: goimports
GO111MODULE=off go vet
goimports:
goimports -w *.go
redomod:
rm -f go.*
goimports -w *.go
GO111MODULE= go mod init
GO111MODULE= go mod tidy
clean:
rm -f go.*
go-mod-clean --purge

1
README.md Normal file
View File

@ -0,0 +1 @@
This code is really hacky still

23
args.go
View File

@ -8,25 +8,24 @@ import (
"go.wit.com/log"
)
var NOW *log.LogFlag
var INFO *log.LogFlag
var SPEW *log.LogFlag
var WARN *log.LogFlag
var CHANGE *log.LogFlag
var STATUS *log.LogFlag
var REPO *log.LogFlag
var REPOWARN *log.LogFlag
func init() {
full := "go.wit.com/gui/gadgets/repostatus"
full := "go.wit.com/lib/gui/repostatus"
short := "repostatus"
NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
INFO = log.NewFlag("INFO", false, full, short, "general repo things")
WARN = log.NewFlag("WARN", true, full, short, "bad things")
SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")
CHANGE = log.NewFlag("CHANGE", true, full, short, "when repo changes")
STATUS = log.NewFlag("STATUS", false, full, short, "current status")
full = "go.wit.com/lib/gui/repo"
short = "repo"
REPO = log.NewFlag("REPO", false, full, short, "general repo things")
REPOWARN = log.NewFlag("REPOWARN", true, full, short, "repo warnings")
}

37
branchesBox.go Normal file
View File

@ -0,0 +1,37 @@
package repostatus
import (
"go.wit.com/gui"
"go.wit.com/log"
)
func (rs *RepoStatus) makeBranchesBox(parent *gui.Node) {
repo := rs.pb
rs.gitBranchesGroup = parent.NewGroup("branches") // `progname:"BRANCHES"` // can the toolkits use these for i18n support?
grid := rs.gitBranchesGroup.RawGrid()
var win *repoBranchesWindow
grid.NewButton("Branches Window", func() {
if win != nil {
win.Toggle()
return
}
log.Info("redo this")
win = MakeRepoBranchesWindow(repo)
win.Show()
})
grid.NextRow()
var mergeWin *repoMergeWindow
grid.NewButton("Merge Window", func() {
if mergeWin != nil {
mergeWin.Toggle()
return
}
log.Info("redo this")
mergeWin = rs.MakeRepoMergeWindow(repo)
mergeWin.Show()
})
grid.NextRow()
}

114
common.go
View File

@ -2,46 +2,51 @@ package repostatus
import (
"go.wit.com/log"
// "go.wit.com/gui/gui"
)
// reports externally if something has changed
// since the last time it was asked about it
func (rs *RepoStatus) Changed() bool {
if ! rs.Ready() {return false}
if rs.changed {
rs.changed = false
return true
func (rs *RepoStatus) Changed() (string, bool) {
if !rs.Ready() {
return "", false
}
return false
return rs.getChanges(), rs.changed
}
func (rs *RepoStatus) Draw() {
if ! rs.Ready() {return}
log.Log(CHANGE, "Draw() window ready =", rs.ready)
rs.window.TestDraw()
// rs.window.Draw()
rs.ready = true
// keeps a human readable list of things that have
// changed. todo: timestampe these?
func (rs *RepoStatus) getChanges() string {
return rs.changes
}
func (rs *RepoStatus) NoteChange(s string) {
rs.changed = true
rs.changes += s + "\n"
}
func (rs *RepoStatus) Show() {
if ! rs.Ready() {return}
if !rs.Ready() {
return
}
log.Log(CHANGE, "Show() window ready =", rs.ready)
rs.window.Show()
rs.hidden = false
}
func (rs *RepoStatus) Hide() {
if ! rs.Ready() {return}
if !rs.Ready() {
return
}
log.Log(CHANGE, "Hide() window ready =", rs.ready)
rs.window.Hide()
rs.hidden = true
}
func (rs *RepoStatus) Toggle() {
if ! rs.Ready() {return}
if !rs.Ready() {
return
}
log.Log(CHANGE, "Toggle() window ready =", rs.ready)
if rs.hidden {
if rs.window.Hidden() {
rs.Show()
} else {
rs.Hide()
@ -49,17 +54,68 @@ func (rs *RepoStatus) Toggle() {
}
func (rs *RepoStatus) Ready() bool {
log.Log(SPEW, "Ready() maybe not ready? rs =", rs)
if rs == nil {return false}
if rs.window == nil {return false}
if rs == nil {
return false
}
if rs.window == nil {
return false
}
return rs.ready
}
/*
func (rs *RepoStatus) Initialized() bool {
log.Log(CHANGE, "checking Initialized()")
if rs == nil {return false}
if rs.parent == nil {return false}
return true
// disable all things besides Update() button
func (rs *RepoStatus) DisableEverything() {
log.Log(INFO, "DisableEverything()")
// choosing a major, minor or revision
rs.major.Disable()
rs.minor.Disable()
rs.revision.Disable()
// disable adding a tag message
rs.versionMessage.Disable()
// disable the merge devel to master button
rs.develMergeB.Disable()
// disable the tag a new version button
rs.releaseVersion.Disable()
}
// this means devel needs to be merged to master
func (rs *RepoStatus) EnableMergeDevel() {
rs.DisableEverything()
rs.develMergeB.Enable()
}
func (rs *RepoStatus) Disable() {
rs.window.Disable()
}
func (rs *RepoStatus) Enable() {
rs.window.Enable()
}
// this means you need to release a new version of the master repository
func (rs *RepoStatus) EnableSelectTag() {
rs.DisableEverything()
// choosing a major, minor or revision
rs.major.Enable()
rs.minor.Enable()
rs.revision.Enable()
// disable adding a tag message
rs.versionMessage.Enable()
rs.develMergeB.SetLabel("ready to release")
if len(rs.versionMessage.String()) == 0 {
// force there to be a commit message
rs.releaseVersion.Disable()
} else {
// rs.generateCmd()
rs.releaseVersion.Enable()
}
}
*/

405
draw.go
View File

@ -1,401 +1,36 @@
package repostatus
import (
"strconv"
"strings"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
)
// creates the actual widgets.
// it's assumed you are always passing in a box
func (rs *RepoStatus) draw() {
if ! rs.Ready() {return}
// display the status of the git repository
rs.drawGitStatus()
// display the git branches and options
rs.drawGitBranches()
// show standard git commit and merge controls
rs.drawGitCommands()
// figure out what the state of the git repository is
// rs.Update()
}
func (rs *RepoStatus) drawGitBranches() {
rs.gitBranchesGroup = rs.window.Box().NewGroup("branches")
newgrid := rs.gitBranchesGroup.NewGrid("gridnuts", 2, 2)
rs.masterDrop = gadgets.NewBasicDropdown(newgrid, "main branch")
rs.develDrop = gadgets.NewBasicDropdown(newgrid, "devel branch")
rs.userDrop = gadgets.NewBasicDropdown(newgrid, "user branch")
var master = ""
all := rs.getBranches()
for _, branch := range all {
log.Warn("getBranches()", branch)
rs.masterDrop.Add(branch)
rs.develDrop.Add(branch)
rs.userDrop.Add(branch)
if branch == "master" {
master = "master"
}
if branch == "main" {
master = "main"
}
}
// relabel the various gadgets with the right branch name
rs.masterBranchVersion.SetLabel(master)
var count *gui.Node
rs.showBranchesButton = newgrid.NewButton("show branches", func() {
all := rs.getBranches()
i := len(all)
count.Set(strconv.Itoa(i) + " branches")
})
count = newgrid.NewLabel("")
rs.checkBranchesButton = newgrid.NewButton("check branches", func() {
if rs.CheckBranches() {
log.Warn("Branches are perfect")
} else {
log.Warn("Branches are not perfect")
}
})
}
func (rs *RepoStatus) drawGitStatus() {
rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has")
func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
rs.gitStatusGroup = box.NewGroup("What GIT Knows It Has")
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
// newgrid.SetNext(1,1)
newgrid.Margin()
newgrid.Pad()
rs.path = gadgets.NewOneLiner(newgrid, "path")
rs.currentBranch = gadgets.NewOneLiner(newgrid, "branch")
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
rs.currentVersion = gadgets.NewOneLiner(newgrid, "Version")
rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "existing tags")
rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
rs.userBranchVersion = gadgets.NewOneLiner(newgrid, "user")
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
rs.goPath = gadgets.NewOneLiner(newgrid, "go path")
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
rs.isGoLang = gadgets.NewOneLiner(newgrid, "Is GO Lang?")
rs.isGoLang.SetText("false")
rs.mainWorkingName = gadgets.NewOneLiner(newgrid, "main working branch")
rs.mainWorkingName.SetValue("???")
rs.develWorkingName = gadgets.NewOneLiner(newgrid, "devel working branch")
rs.develWorkingName.SetValue("devel")
rs.userWorkingName = gadgets.NewOneLiner(newgrid, "user working branch")
rs.userWorkingName.SetValue("uid")
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
rs.gitState = gadgets.NewOneLiner(newgrid, "git state")
rs.readOnly = gadgets.NewOneLiner(newgrid, "read only")
rs.primitive = gadgets.NewOneLiner(newgrid, "primitive")
rs.private = gadgets.NewOneLiner(newgrid, "private")
rs.targetReleaseVersion = gadgets.NewOneLiner(newgrid, "target release version")
rs.speed = gadgets.NewOneLiner(newgrid, "refresh speed =")
rs.speedActual = gadgets.NewOneLiner(newgrid, "speed actual =")
}
func (rs *RepoStatus) drawGitCommands() {
rs.gitCommandsGroup = rs.window.Box().NewGroup("git commands")
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 2, 2)
newgrid.NewButton("update", func() {
rs.Update()
})
label := "merge devel to " + rs.masterDrop.Get()
rs.develMerge = newgrid.NewButton(label, func() {
rs.develMerge.Disable()
master := rs.masterDrop.Get()
rs.checkoutBranch("master", master)
if rs.getCurrentBranchName() != master {
log.Warn("something went wrong switching to the master branch. full stop!")
return
}
if ! rs.runGitCommands() {
log.Warn("SOMETHING WENT WRONG")
return
}
rs.Update()
log.Warn("THINGS SEEM OK")
})
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
rs.major.Custom = func () {
rs.setTag()
rs.generateCmd()
}
rs.minor = gadgets.NewBasicCombobox(newgrid, "minor")
rs.minor.Custom = func () {
rs.setTag()
rs.generateCmd()
}
rs.revision = gadgets.NewBasicCombobox(newgrid, "revision")
rs.revision.Custom = func () {
rs.setTag()
rs.generateCmd()
}
newgrid.NewLabel("new tag version")
rs.newversion = newgrid.NewLabel("3.1.4")
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
rs.versionMessage.Custom = func () {
rs.generateCmd()
}
rs.versionCmdOutput = gadgets.NewOneLiner(newgrid, "tag cmd")
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
if ! rs.generateCmd() {
log.Warn("something is wrong. fix the errors first")
return
}
log.Warn("COMMIT IT HERE")
if ! rs.runGitCommands() {
log.Warn("SOMETHING WENT WRONG")
}
rs.Update()
log.Warn("THINGS SEEM OK")
})
newgrid.Margin()
newgrid.Pad()
}
func (rs *RepoStatus) setTag() bool {
lasttag := rs.lasttag.Get()
var major, minor, revision string
major, minor, revision = splitVersion(lasttag)
olda, _ := strconv.Atoi(major)
oldb, _ := strconv.Atoi(minor)
oldc, _ := strconv.Atoi(revision)
log.Warn("current version here", lasttag)
log.Warn("current release a,b,c =", major, minor, revision)
newa, _ := strconv.Atoi(rs.major.Get())
newver := strconv.Itoa(newa)
if newa < olda {
log.Warn("new version bad", newver, "vs old version", lasttag, "newa =", newa, "olda =", olda)
rs.newversion.Set("bad")
return false
}
if newa > olda {
log.Warn("new version ok", newver, "vs old version", lasttag)
rs.newversion.Set(newver)
rs.minor.Set("")
rs.revision.Set("")
return true
}
newb, _ := strconv.Atoi(rs.minor.Get())
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb)
if newb < oldb {
log.Warn("new version bad", newver, "vs old version", lasttag, "newb =", newb, "oldb =", oldb)
rs.newversion.Set("bad")
return false
}
if newb > oldb {
log.Warn("new version ok", newver, "vs old version", lasttag)
rs.newversion.Set(newver)
rs.revision.Set("")
return true
}
newc, _ := strconv.Atoi(rs.revision.Get())
newver = strconv.Itoa(newa) + "." + strconv.Itoa(newb) + "." + strconv.Itoa(newc)
if newc <= oldc {
log.Warn("new version bad", newver, "vs old version", lasttag)
rs.newversion.Set("bad")
return false
}
log.Warn("new version ok", newver, "vs old version", lasttag)
rs.newversion.Set(newver)
return true
}
func (rs *RepoStatus) incrementVersion() {
lasttag := rs.lasttag.Get()
var major, minor, revision string
major, minor, revision = splitVersion(lasttag)
log.Warn("Should release version here", lasttag)
log.Warn("Should release a,b,c", major, minor, revision)
a, _ := strconv.Atoi(major)
b, _ := strconv.Atoi(minor)
c, _ := strconv.Atoi(revision)
rs.major.Add(a)
rs.major.Add(a + 1)
rs.major.Set(a)
rs.minor.Add(b)
rs.minor.Add(b + 1)
rs.minor.Set(b)
// rs.c := strconv.Atoi(revision)
rs.revision.Add(c + 1)
rs.revision.Add(c + 2)
rs.revision.Set(c + 1)
}
func (rs *RepoStatus) recommend() {
log.Warn("Is repo dirty?", rs.dirtyLabel.Get())
log.Warn("list the known tags")
rs.DisableEverything()
rs.populateTags()
log.Warn("Does devel == user?", rs.develBranchVersion.Get(), rs.userBranchVersion.Get())
if rs.develBranchVersion.Get() != rs.userBranchVersion.Get() {
log.Warn("devel does not equal user")
log.Warn("merge or squash?")
rs.EnableMergeDevel()
rs.setMergeUserCommands()
label := "merge " + rs.GetUserName() + " into " + rs.GetDevelName()
rs.develMerge.SetText(label)
return
}
log.Warn("Does master == devel? ", rs.masterBranchVersion.Get(), rs.develBranchVersion.Get())
if rs.masterBranchVersion.Get() != rs.develBranchVersion.Get() {
log.Warn("master does not equal devel. merge devel into master")
rs.EnableMergeDevel()
rs.setMergeDevelCommands()
label := "merge " + rs.GetDevelName() + " into " + rs.GetMasterName()
rs.develMerge.SetText(label)
return
}
rs.getLastTagVersion()
if rs.lasttag.Get() != rs.masterBranchVersion.Get() {
log.Warn("master does not equal last tag")
rs.incrementVersion()
rs.EnableSelectTag()
rs.setTag()
return
}
log.Warn("Is repo pushed upstream? git.wit.org or github?")
}
func (rs *RepoStatus) generateCmd() bool {
// the length of 24 is arbitrary, but should be short
// they should be things like perhaps, major release names
// or something the users might see.
// aka: "Topsy", "Picasso", "Buzz", etc
if ! rs.setTag() {
log.Warn("tag sucked. fix your tag version")
rs.versionMessage.SetLabel("tag message (bad version)")
rs.releaseVersion.Disable()
return false
}
log.Warn("tag is valid!!!!")
rs.setGitCommands()
if rs.versionMessage.Get() == "" {
log.Warn("tag message is empty!!!!")
rs.releaseVersion.Disable()
return false
}
if len(rs.versionMessage.Get()) > 24 {
rs.versionMessage.SetLabel("tag message (too long)")
} else {
rs.versionMessage.SetLabel("tag message")
}
rs.releaseVersion.Enable()
return true
}
func (rs *RepoStatus) runGitCommands() bool {
for _, line := range rs.versionCmds {
s := strings.Join(line, " ")
log.Warn("NEED TO RUN:", s)
rs.develMerge.SetText(s)
err, b, output := runCmd(rs.repopath, line)
if err != nil {
log.Warn("ABEND EXECUTION")
log.Warn("error =", err)
log.Warn("output =", output)
return false
}
log.Warn("Returned with b =", b)
log.Warn("output was =", output)
log.Warn("RUN DONE")
}
return true
}
func (rs *RepoStatus) setGitCommands() {
var line1, line2, line3 []string
var all [][]string
newTag := rs.newversion.GetText()
line1 = append(line1, "git", "tag", "v" + newTag, "-m", rs.versionMessage.Get())
all = append(all, line1)
line2 = append(line2, "git", "push", "--tags")
all = append(all, line2)
line3 = append(line3, "git", "push", "--prune", "--tags")
all = append(all, line3)
rs.versionCmds = all
var tmp []string
// convert to displayable to the user text
for _, line := range all {
s := strings.Join(line, " ")
log.Warn("s =", s)
tmp = append(tmp, s)
}
rs.versionCmdOutput.Set(strings.Join(tmp, "\n"))
}
func (rs *RepoStatus) setMergeDevelCommands() {
var line1, line2, line3 []string
var all [][]string
master := rs.GetMasterName()
devel := rs.GetDevelName()
line1 = append(line1, "git", "checkout", master)
all = append(all, line1)
line2 = append(line2, "git", "merge", devel)
all = append(all, line2)
line3 = append(line3, "git", "push")
all = append(all, line3)
rs.versionCmds = all
var tmp []string
// convert to displayable to the user text
for _, line := range all {
s := strings.Join(line, " ")
log.Warn("s =", s)
tmp = append(tmp, s)
}
rs.versionCmdOutput.Set(strings.Join(tmp, "\n"))
}
func (rs *RepoStatus) setMergeUserCommands() {
var line1, line2, line3 []string
var all [][]string
devel := rs.GetDevelName()
user := rs.GetUserName()
line1 = append(line1, "git", "checkout", devel)
all = append(all, line1)
line2 = append(line2, "git", "merge", user)
all = append(all, line2)
line3 = append(line3, "git", "push")
all = append(all, line3)
rs.versionCmds = all
var tmp []string
// convert to displayable to the user text
for _, line := range all {
s := strings.Join(line, " ")
log.Warn("s =", s)
tmp = append(tmp, s)
}
rs.versionCmdOutput.Set(strings.Join(tmp, "\n"))
}

238
git.go
View File

@ -1,222 +1,42 @@
package repostatus
import (
"strings"
"unicode/utf8"
"io/ioutil"
"go.wit.com/log"
)
func (rs *RepoStatus) GetCurrentBranchName() string {
return rs.currentBranch.Get()
}
func (rs *RepoStatus) GetCurrentBranchVersion() string {
return rs.currentVersion.Get()
}
func (rs *RepoStatus) GetLastTagVersion() string {
return rs.lasttag.Get()
}
func (rs *RepoStatus) getCurrentBranchName() string {
out := run(rs.repopath, "git", "branch --show-current")
log.Warn("getCurrentBranchName() =", out)
rs.currentBranch.Set(out)
return out
}
func (rs *RepoStatus) getCurrentBranchVersion() string {
out := run(rs.repopath, "git", "describe --tags")
log.Warn("getCurrentBranchVersion()", out)
rs.currentVersion.Set(out)
return out
}
func (rs *RepoStatus) getLastTagVersion() string {
out := run(rs.repopath, "git", "rev-list --tags --max-count=1")
log.Warn("getLastTagVersion()", out)
rs.lasttagrev = out
lastreal := "describe --tags " + out
// out = run(r.path, "git", "describe --tags c871d5ecf051a7dc4e3a77157cdbc0a457eb9ae1")
out = run(rs.repopath, "git", lastreal)
rs.lasttag.Set(out)
rs.tagsDrop.Set(out)
// rs.lastLabel.Set(out)
return out
}
func (rs *RepoStatus) populateTags() {
tmp := fullpath(rs.repopath + "/.git/refs/tags")
log.Warn("populateTags() path =", tmp)
for _, tag := range listFiles(tmp) {
if rs.tags[tag] == "" {
log.Warn("populateTags() Adding new tag", tag)
rs.tagsDrop.Add(tag)
rs.tags[tag] = "origin"
}
}
// rs.tagsDrop.Set(rs.lasttagrev)
// most everything here needs to be deprecated now
func (rs *RepoStatus) Path() string {
return rs.realPath.String()
}
/*
.git/refs/remotes
.git/refs/remotes/github
.git/refs/remotes/github/devel
.git/refs/remotes/github/main
.git/refs/remotes/origin
.git/refs/remotes/origin/devel
.git/refs/remotes/origin/main
.git/refs/remotes/origin/jcarr
.git/refs/heads
func (rs *RepoStatus) GitState() string {
return rs.gitState.String()
}
*/
func (rs *RepoStatus) getBranches() []string {
var all []string
var heads []string
var remotes []string
heads = listFiles(fullpath(rs.repopath + "/.git/refs/heads"))
remotes = listFiles(fullpath(rs.repopath + "/.git/refs/remotes"))
func (rs *RepoStatus) GetStatus() string {
return rs.gitState.String()
}
all = heads
func (rs *RepoStatus) GetLastTagVersion() string {
return rs.lasttag.String()
}
all = append(all, remotes...)
func (rs *RepoStatus) displayCurrentBranchName() string {
out := rs.pb.GetCurrentBranchName()
rs.currentBranch.SetValue(out)
return out
}
for _, branch := range all {
log.Warn("getBranches()", branch)
// stores the current branch name
func (rs *RepoStatus) checkCurrentBranchName() string {
currentname := rs.currentBranch.String()
out := rs.pb.GetCurrentBranchName()
if currentname == out {
// nothing changed
return currentname
}
return all
}
func (rs *RepoStatus) CheckDirty() bool {
out := run(rs.repopath, "git", "diff-index HEAD")
if out == "" {
log.Warn("CheckDirty() no", rs.repopath)
rs.dirtyLabel.Set("no")
return false
} else {
log.Warn("CheckDirty() true", rs.repopath)
rs.dirtyLabel.Set("dirty")
return true
rs.currentBranch.SetValue(out)
if currentname == "" {
return out // don't note if there was nothing before
}
}
func (rs *RepoStatus) checkoutBranch(level string, branch string) {
if rs.CheckDirty() {
log.Warn("checkoutBranch() checkDirty() == true for repo", rs.repopath, "looking for branch:", branch)
return
}
out := run(rs.repopath, "git", "checkout " + branch)
log.Warn(rs.repopath, "git checkout " + branch, "returned", out)
realname := rs.getCurrentBranchName()
realversion := rs.getCurrentBranchVersion()
log.Warn(rs.repopath, "realname =", realname, "realversion =", realversion)
switch level {
case "master":
rs.masterBranchVersion.Set(realversion)
case "devel":
rs.develBranchVersion.Set(realversion)
case "user":
rs.userBranchVersion.Set(realversion)
default:
}
}
func (rs *RepoStatus) SetMasterName(s string) {
rs.masterDrop.Set(s)
rs.masterBranchVersion.SetLabel(s)
// rs.major.SetTitle(s)
}
func (rs *RepoStatus) SetDevelName(s string) {
rs.develDrop.Set(s)
rs.develBranchVersion.SetLabel(s)
}
func (rs *RepoStatus) SetUserName(s string) {
rs.userDrop.Set(s)
rs.userBranchVersion.SetLabel(s)
}
// returns "master", "devel", os.Username, etc
func (rs *RepoStatus) GetMasterName() string {
name := rs.masterDrop.Get()
log.Warn("GetMasterName() =", name)
return name
}
func (rs *RepoStatus) GetDevelName() string {
name := rs.develDrop.Get()
log.Warn("GetDevelName() =", name)
return name
}
func (rs *RepoStatus) GetUserName() string {
name := rs.userDrop.Get()
log.Warn("GetUserName() =", name)
return name
}
// returns the git versions like "1.3-2-laksdjf" or whatever
func (rs *RepoStatus) GetMasterVersion() string {
name := rs.masterBranchVersion.Get()
log.Warn("GetMasterVersion() =", name)
return name
}
func (rs *RepoStatus) GetDevelVersion() string {
name := rs.develBranchVersion.Get()
log.Warn("GetBranchVersion() =", name)
return name
}
func (rs *RepoStatus) GetUserVersion() string {
name := rs.userBranchVersion.Get()
log.Warn("GetUserVersion() =", name)
return name
}
func (rs *RepoStatus) CheckBranches() bool {
var hashCheck string
var perfect bool = true
all := rs.getBranches()
path := fullpath(rs.repopath + "/.git/refs/")
for _, b := range all {
parts := strings.Split(b, "/")
rdir := "heads"
if len(parts) == 2 {
rdir = "remotes"
}
fullfile := path + "/" + rdir + "/" + b
// check if the ref name is "HEAD". if so, skip
runeCount := utf8.RuneCountInString(fullfile)
// Convert the string to a slice of runes
runes := []rune(fullfile)
// Slice the last 4 runes
lastFour := runes[runeCount-4:]
if string(lastFour) == "HEAD" {
log.Warn("skip HEAD fullfile", fullfile)
continue
}
content, _ := ioutil.ReadFile(fullfile)
hash := strings.TrimSpace(string(content))
if hashCheck == "" {
hashCheck = hash
}
var cmd []string
cmd = append(cmd, "git", "show", "-s", "--format=%ci", hash)
_, _, output := runCmd(rs.repopath, cmd)
// git show -s --format=%ci <hash> will give you the time
// log.Warn(fullfile)
if hash == hashCheck {
log.Warn(hash, output, b)
} else {
log.Warn(hash, output, b, "NOT THE SAME")
perfect = false
parts := strings.Split(b, "/")
log.Warn("git push", parts)
}
}
return perfect
rs.NoteChange("current branch has changed from " + currentname + " to " + out)
return out
}

16
go.mod
View File

@ -1,16 +0,0 @@
module go.wit.com/gui/gadgets/repostatus
go 1.21.4
require (
go.wit.com/gui/gadgets v0.12.3
go.wit.com/gui/gui v0.12.8
go.wit.com/log v0.5.3
)
require (
go.wit.com/dev/alexflint/arg v1.4.5 // indirect
go.wit.com/dev/alexflint/scalar v1.2.1 // indirect
go.wit.com/dev/davecgh/spew v1.1.3 // indirect
go.wit.com/gui/widget v1.1.3 // indirect
)

14
go.sum
View File

@ -1,14 +0,0 @@
go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY=
go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0=
go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
go.wit.com/dev/davecgh/spew v1.1.3 h1:hqnB5qsPgC2cLZaJXqQJspQ5n/Ugry9kyL3tLk0hVzQ=
go.wit.com/dev/davecgh/spew v1.1.3/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
go.wit.com/gui/gadgets v0.12.3 h1:jy7I5fYUkwywq5HiYtpkuhNpixF0myRHliHSX9Xn2l4=
go.wit.com/gui/gadgets v0.12.3/go.mod h1:Wem8Gn+dyDhYXrKl+LCojYz4X9c1KsT65EAUNzQsUaY=
go.wit.com/gui/gui v0.12.8 h1:YJ7YjdP9+vwWYVvMakaJPPpfPt9g33Iw0xfuwNQZkmA=
go.wit.com/gui/gui v0.12.8/go.mod h1:iALRA0qw7mn82MX21wrU0FOq/vR9l27If7ObNdOSlNE=
go.wit.com/gui/widget v1.1.3 h1:GvLzGSOF9tfmoh6HNbFdN+NSlBo2qeS/Ba2TnQQ1A1U=
go.wit.com/gui/widget v1.1.3/go.mod h1:A6/FaiFQtAHTjgo7c4FrokXe6bXX1Cowo35b2Lgi31E=
go.wit.com/log v0.5.3 h1:/zHkniOPusPEuX1R401rMny9uwSO/nSU/QOMx6qoEnE=
go.wit.com/log v0.5.3/go.mod h1:LzIzVxc2xJQxWQBtV9VbV605P4TOxmYDCl+BZF38yGE=

22
new.go
View File

@ -1,22 +0,0 @@
package repostatus
import (
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
)
func New(p *gui.Node, path string) *RepoStatus {
rs := &RepoStatus {
hidden: true,
ready: false,
parent: p,
repopath: path,
}
rs.tags = make(map[string]string)
rs.window = gadgets.NewBasicWindow(p, "GO Repo Details " + path)
rs.window.Horizontal()
rs.window.Make()
rs.ready = true
rs.draw()
return rs
}

View File

@ -1,49 +1,66 @@
package repostatus
import (
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
)
type RepoStatus struct {
ready bool
hidden bool
changed bool
changed bool // keeps track of changes that might have happened
changes string
// tags map[string]string
InitOk bool // it takes a second or so to init these
repopath string
lasttagrev string
tags map[string]string
pb *gitpb.Repo // the protobuf
parent *gui.Node
// used to temporarily tell the automation tools to
// try to ignore this repo's changes and state
// specifically when doing formal releases, sometimes
// some repos are in flux and can't be changed. This
// means attempt to overlook that situation.
Whitelist bool
window *gadgets.BasicWindow
// group *gui.Node
// grid *gui.Node
window *gadgets.BasicWindow // the main window for this repo
Tags *GitTagBox // a box of all the git tags
// status *gadgets.OneLiner
dirtyLabel *gadgets.OneLiner
dirtyList string // the output from git status --porcelain
readOnly *gadgets.OneLiner
gitState *gadgets.OneLiner
primitive *gadgets.OneLiner // aka: doesn't have a go.sum file
private *gadgets.OneLiner // it's not possible to publish this to pkg.go.dev
protobuf *gadgets.OneLiner // is this repo a protobuf repo?
path *gadgets.OneLiner
goSrcPath *gadgets.OneLiner
goPath *gadgets.OneLiner
realPath *gadgets.OneLiner
isGoLang *gadgets.OneLiner
currentBranch *gadgets.OneLiner
currentVersion *gadgets.OneLiner
tagsDrop *gadgets.BasicDropdown
lasttag *gadgets.OneLiner
masterBranchVersion *gadgets.OneLiner
develBranchVersion *gadgets.OneLiner
userBranchVersion *gadgets.OneLiner
develMerge *gui.Node
releaseVersion *gui.Node
// vgroup *gui.Node
minor *gadgets.BasicCombobox
major *gadgets.BasicCombobox
revision *gadgets.BasicCombobox
mainWorkingName *gadgets.OneLiner // the actual name of the primary branch
develWorkingName *gadgets.OneLiner // the actual name of the devel branch
userWorkingName *gadgets.OneLiner // the actual name of the user branch
develMergeB *gui.Node // button to merge from user to devel
mainMergeB *gui.Node // button to merge from devel to master
releaseVersion *gui.Node // the release version
minor *gadgets.BasicCombobox // the '3' in version v3.1.4
major *gadgets.BasicCombobox // the '1' in version v3.1.4
revision *gadgets.BasicCombobox // the '4' in version v3.1.4
lasttag *gadgets.OneLiner // the last tag version
mainBranchVersion *gadgets.OneLiner // the primary branch version
develBranchVersion *gadgets.OneLiner // the devel branch version
userBranchVersion *gadgets.OneLiner // the user branch version
versionMessage *gadgets.BasicEntry
versionCmds [][]string
versionCmdOutput *gadgets.OneLiner
targetReleaseVersion *gadgets.OneLiner
newversion *gui.Node
@ -51,13 +68,15 @@ type RepoStatus struct {
gitStatusGroup *gui.Node
gitCommandsGroup *gui.Node
masterDrop *gadgets.BasicDropdown
develDrop *gadgets.BasicDropdown
userDrop *gadgets.BasicDropdown
showBranchesButton *gui.Node
checkBranchesButton *gui.Node
speed *gadgets.OneLiner
speedActual *gadgets.OneLiner
// gitConfig *GitConfig
// goConfig GoConfig
switchBranchB *gui.Node
targetBranch *gui.Node
}

388
tagWindow.go Normal file
View File

@ -0,0 +1,388 @@
package repostatus
import (
"errors"
"path/filepath"
"regexp"
"strings"
"sync"
"time"
"go.wit.com/gui"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
type Tag struct {
// tracks if the tag is displayed
hidden bool
// the tag "v0.1.3"
tag *gui.Node
// the .git/ref hash
ref *gui.Node
// the .git/ref date
date *gui.Node
duration *gui.Node
// the tag comment
subject *gui.Node
// a button to delete the tag
deleteB *gui.Node
}
// a GUI box of all the tags in a repo
type GitTagBox struct {
// the box to list all the tags in
box *gui.Node
group *gui.Node
grid *gui.Node
// all the tags
tags []*Tag
}
func (rs *RepoStatus) makeTagBox(box *gui.Node) error {
if rs.Tags != nil {
log.Log(WARN, "already scanned tags")
return errors.New("already scanned tags")
}
tagB := new(GitTagBox)
rs.Tags = tagB
tagB.group = box.NewGroup(".git tags for " + rs.Path())
// tagB.group.NewButton("prune tags", func() {
// tagB.Prune()
// })
var dups *gui.Node
dups = tagB.group.NewCheckbox("Show duplicate tags").SetChecked(false)
dups.Custom = func() {
if dups.Checked() {
tagB.Prune()
} else {
for _, t := range tagB.tags {
t.Show()
}
}
}
tagB.group.NewButton("delete all", func() {
/*
for i, t := range tagB.tags {
if t.hidden {
// log.Info("tag is hidden", i, t.tag.String())
continue
}
log.Info("tag is shown", i, t.tag.String())
// rs.DeleteTag(t)
}
*/
})
grid := tagB.group.NewGrid("tags", 0, 0)
tagB.grid = grid
grid.NewLabel("version")
grid.NewLabel("ref")
grid.NewLabel("date")
grid.NewLabel("release subject")
grid.NextRow() // works like a typerwriter newline
loop := rs.pb.Tags.SortByAge()
for loop.Scan() {
tag := loop.Next()
rTag := new(Tag)
rTag.tag = grid.NewLabel(tag.GetRefname())
rTag.ref = grid.NewEntrybox(tag.GetHash())
ctime := tag.GetAuthordate().AsTime()
dur := shell.GetDurationStamp(ctime)
rTag.date = grid.NewLabel(ctime.Format("YYYY/MM/DD"))
rTag.duration = grid.NewLabel(dur)
rTag.subject = grid.NewLabel(tag.GetSubject())
rTag.deleteB = grid.NewButton("delete", func() {
/*
tagversion := tag.GetRefname()
log.Info("remove tag", tagversion)
var all [][]string
all = append(all, []string{"git", "tag", "--delete", tagversion})
all = append(all, []string{"git", "push", "--delete", "origin", tagversion})
if rs.DoAll(all) {
log.Info("TAG DELETED", rs.Path(), tagversion)
} else {
log.Info("TAG DELETE FAILED", rs.Path(), tagversion)
}
*/
})
tagB.tags = append(tagB.tags, rTag)
// works like a typerwriter
grid.NextRow()
}
return nil
}
func (rtags *GitTagBox) ListAll() []*Tag {
var tags []*Tag
for _, t := range rtags.tags {
tags = append(tags, t)
}
return tags
}
func (rtags *GitTagBox) List() []*Tag {
var tags []*Tag
for _, t := range rtags.tags {
if t.hidden {
// log.Info("tag is hidden", i, t.tag.String())
continue
}
// log.Info("tag is shown", t.tag.String(), rtags.rs.String())
tags = append(tags, t)
}
return tags
}
func (rtags *GitTagBox) Prune() {
dups := make(map[string]*Tag)
for i, t := range rtags.tags {
if t == nil {
log.Info("tag empty:", i)
continue
}
ref := t.ref.String()
_, ok := dups[ref]
if ok {
log.Info("tag is duplicate:", i, t.tag.String())
} else {
log.Info("new tag", i, t.tag.String())
dups[ref] = t
t.Hide()
}
}
}
// hide tags worth keeping
func (rtags *GitTagBox) PruneSmart() {
// always keep the first tag
var first bool = true
dups := make(map[string]*Tag)
for i, t := range rtags.tags {
if t == nil {
log.Info("tag empty:", i)
continue
}
// check for duplicate tags
ref := t.ref.String()
_, ok := dups[ref]
if ok {
log.Info("tag is duplicate:", i, t.tag.String())
continue
}
dups[ref] = t
// dump any tags that don't start with 'v'
//if !strings.HasPrefix(t.tag.String(), "v") {
// log.Info("tag does not start with v", i, t.tag.String())
// continue
//}
isVersion := regexp.MustCompile("v[0-9]+.[0-9]+.[0-9]+").MatchString
if isVersion(t.tag.String()) {
if first {
log.Info("keep first tag", i, t.tag.String())
t.Hide()
first = false
continue
}
log.Info("valid tag", i, t.tag.String())
t.Hide()
continue
}
if first {
log.Info("keep first tag", i, t.tag.String())
t.Hide()
first = false
continue
}
log.Info("keep tag", i, t.tag.String())
}
}
/*
// deleting it locally triggers some but when
// the git server was uncontactable (over IPv6 if that matters, probably it doesn't)
// and then the local delete re-added it into the tag
func (rs *RepoStatus) DeleteTag(rt *Tag) {
cmd := []string{"git", "push", "--delete", "origin", rt.tag.String()}
log.Info("RUN:", cmd)
r := rs.Run(cmd)
output := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Info("cmd failed", r.Error)
log.Info("output:", output)
}
log.Info("output:", output)
cmd = []string{"git", "tag", "--delete", rt.tag.String()}
log.Info("RUN:", cmd)
r = rs.Run(cmd)
output = strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Info("cmd failed", r.Error)
log.Info("output:", output)
}
log.Info("output:", output)
}
*/
func (rt *Tag) TagString() string {
return rt.tag.String()
}
func (rt *Tag) Hide() {
rt.hidden = true
rt.tag.Hide()
rt.ref.Hide()
rt.date.Hide()
rt.duration.Hide()
rt.subject.Hide()
rt.deleteB.Hide()
}
func (rt *Tag) Show() {
rt.hidden = false
rt.tag.Show()
rt.ref.Show()
rt.date.Show()
rt.duration.Show()
rt.subject.Show()
rt.deleteB.Show()
}
func (rs *RepoStatus) TagExists(findname string) bool {
allTags := rs.Tags.ListAll()
for _, t := range allTags {
tagname := t.TagString()
_, filename := filepath.Split(tagname)
if filename == findname {
// log.Info("found tag:", path, filename, "from", rs.Path())
return true
}
}
return false
}
func (rs *RepoStatus) LocalTagExists(findname string) bool {
allTags := rs.Tags.ListAll()
for _, t := range allTags {
tagname := t.TagString()
if strings.HasPrefix(tagname, "refs/remotes") {
continue
}
path, filename := filepath.Split(tagname)
log.Log(INFO, "tag:", path, filename, "from", rs.Path())
if filename == findname {
log.Log(INFO, "found tag:", path, filename, "from", rs.Path())
return true
}
}
return false
}
// returns true if 'taggy' is _ONLY_ a local tag
// this means you can not do a git pull or git push on it
func (rs *RepoStatus) IsOnlyLocalTag(taggy string) bool {
// first make sure the tag is actually even local
if !rs.LocalTagExists(taggy) {
// this means it's not even local now.
return false
}
// okay, taggy exists, does it exist in a remote repo?
for _, t := range rs.Tags.ListAll() {
tagname := t.TagString()
if strings.HasPrefix(tagname, "refs/remotes") {
path, filename := filepath.Split(tagname)
if filename == taggy {
log.Log(REPOWARN, "found tag:", path, filename, "from", rs.Path())
return false
}
}
}
// we couldn't find the local tag anywhere remote, so it's probably only local
return true
}
func (t *Tag) Age() time.Duration {
const gitLayout = "Mon Jan 2 15:04:05 2006 -0700"
tagTime, _ := time.Parse(gitLayout, t.date.String())
return time.Since(tagTime)
}
func (t *Tag) Name() string {
return t.tag.String()
}
func (t *Tag) GetDate() (time.Time, error) {
const gitLayout = "Mon Jan 2 15:04:05 2006 -0700"
tagTime, err := time.Parse(gitLayout, t.date.String())
if err != nil {
log.Log(REPOWARN, "tag date err", t.ref.String(), t.tag.String(), err)
return time.Now(), err
}
return tagTime, nil
}
func (rs *RepoStatus) NewestTag() *Tag {
var newest *Tag
var newestTime time.Time
var tagTime time.Time
var err error
var allTags []*Tag
var mu sync.Mutex
allTags = make([]*Tag, 0, 0)
junk := rs.Tags.ListAll()
allTags = append(allTags, junk...)
for _, t := range allTags {
mu.Lock()
if tagTime, err = t.GetDate(); err != nil {
mu.Unlock()
continue
}
// log.Log(REPOWARN, "tag", t.ref.String(), t.date.String(), t.tag.String())
// if this is the first tag, use it
if newest == nil {
newestTime = tagTime
newest = t
}
// if the tag date is after the newest date, it's newer so use this tag
if tagTime.After(newestTime) {
newestTime = tagTime
newest = t
}
mu.Unlock()
}
return newest
}
func (rs *RepoStatus) DumpTags() {
for _, t := range rs.Tags.ListAll() {
log.Log(REPOWARN, "tag", t.ref.String(), t.date.String(), t.tag.String())
}
}

View File

@ -1,17 +0,0 @@
package repostatus
import (
"time"
)
// timeFunction takes a function as an argument and returns the execution time.
func timeFunction(f func()) time.Duration {
startTime := time.Now() // Record the start time
f() // Execute the function
return time.Since(startTime) // Calculate the elapsed time
}
func (ls *RepoStatus) SetSpeedActual(s string) {
if ! ls.Ready() {return}
ls.speedActual.Set(s)
}

188
unix.go
View File

@ -1,188 +0,0 @@
// This is a simple example
package repostatus
import (
"os"
"os/exec"
"os/user"
"strings"
"regexp"
"errors"
"path/filepath"
"go.wit.com/log"
)
func fullpath(repo string) string {
return "/home/jcarr/go/src/" + repo
}
func run(path string, thing string, cmdline string) string {
parts := strings.Split(cmdline, " ")
// Create the command
cmd := exec.Command(thing, parts...)
// Set the working directory
cmd.Dir = fullpath(path)
// Execute the command
output, err := cmd.CombinedOutput()
if err != nil {
log.Error(err, "cmd error'd out", parts)
return ""
}
tmp := string(output)
tmp = strings.TrimSpace(tmp)
// Print the output
log.Log(WARN, "run()", path, thing, cmdline, "=", tmp)
return tmp
}
// goes in one directory so it gets remote branch names
func listFiles(directory string) []string {
var files []string
fileInfo, err := os.ReadDir(directory)
if err != nil {
log.Error(err)
return nil
}
for _, file := range fileInfo {
if file.IsDir() {
dirname := file.Name()
newdir, _ := os.ReadDir(directory + "/" + dirname)
for _, file := range newdir {
if ! file.IsDir() {
files = append(files, dirname + "/" + file.Name())
}
}
} else {
files = append(files, file.Name())
}
}
return files
}
/*
// string handling examples that might be helpful for normalizeInt()
isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString
for _, username := range []string{"userone", "user2", "user-three"} {
if !isAlpha(username) {
log.Log(GUI, "%q is not valid\n", username)
}
}
const alpha = "abcdefghijklmnopqrstuvwxyz"
func alphaOnly(s string) bool {
for _, char := range s {
if !strings.Contains(alpha, strings.ToLower(string(char))) {
return false
}
}
return true
}
*/
func normalizeVersion(s string) string {
// reg, err := regexp.Compile("[^a-zA-Z0-9]+")
parts := strings.Split(s, "-")
if len(parts) == 0 { return "" }
reg, err := regexp.Compile("[^0-9.]+")
if err != nil {
log.Log(WARN, "normalizeVersion() regexp.Compile() ERROR =", err)
return parts[0]
}
clean := reg.ReplaceAllString(parts[0], "")
log.Log(WARN, "normalizeVersion() s =", clean)
return clean
}
func splitVersion(version string) (a, b, c string) {
tmp := normalizeVersion(version)
parts := strings.Split(tmp, ".")
switch len(parts) {
case 1:
return parts[0], "", ""
case 2:
return parts[0], parts[1], ""
default:
return parts[0], parts[1], parts[2]
}
}
func runCmd(path string, parts []string) (error, bool, string) {
if len(parts) == 0 {
log.Warn("command line was empty")
return errors.New("empty"), false, ""
}
if parts[0] == "" {
log.Warn("command line was empty")
return errors.New("empty"), false, ""
}
thing := parts[0]
parts = parts[1:]
log.Verbose("path =", path, "thing =", thing, "cmdline =", parts)
// Create the command
cmd := exec.Command(thing, parts...)
// Set the working directory
cmd.Dir = fullpath(path)
// Execute the command
output, err := cmd.CombinedOutput()
if err != nil {
log.Error(err)
log.Warn("output was", output)
log.Warn("cmd exited with error", err)
return err, false, string(output)
}
tmp := string(output)
tmp = strings.TrimSpace(tmp)
// Print the output
return nil, true, tmp
}
// Set the path to the package
// Replace this with the actual path to the github.com/coredns/coredns directory
func getfiles(pathToPackage string) {
// List files in the directory
err := filepath.Walk(pathToPackage, nil) // compiles but crashes
if err == nil {
log.Warn("directory ok", pathToPackage)
} else {
log.Warn("directory wrong", pathToPackage)
}
}
func IsDirectory(path string) bool {
info, err := os.Stat(path)
if err != nil {
return false
}
return info.IsDir()
}
func VerifyLocalGoRepo(gorepo string) bool {
// Get current user
usr, err := user.Current()
if err != nil {
log.Error(err, "VerifyLocalGoRepo() thinks you should switch to Ultrix")
return false
}
// Form the path to the home Git directory
gitDir := filepath.Join(usr.HomeDir, "go/src/", gorepo, ".git")
log.Warn("go directory:", gitDir)
return IsDirectory(gitDir)
}

128
update.go
View File

@ -1,119 +1,49 @@
package repostatus
import (
"fmt"
"time"
"errors"
"go.wit.com/log"
)
func (rs *RepoStatus) Update() {
if ! rs.Ready() {
if !rs.Ready() {
log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet"))
return
}
log.Log(WARN, "Update() START")
duration := timeFunction(func () {
// do things that are safe even if the git tree is dirty
log.Warn("path.Set()")
rs.path.Set(rs.repopath)
log.Warn("getCurrentBranchName()")
rs.getCurrentBranchName()
log.Warn("set window Title()")
rs.window.Title(rs.repopath + " GO repo Details")
log.Warn("getCurrentBranchVersion()")
rs.getCurrentBranchVersion()
log.Warn("getLastTagVersion()")
rs.getLastTagVersion()
log.Warn("populateTags()")
rs.populateTags()
log.Warn("CheckDirty()")
rs.CheckDirty()
if rs.dirtyLabel.Get() != "no" {
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get())
rs.DisableEverything()
return
}
pb := rs.pb
master := rs.masterDrop.Get()
devel := rs.develDrop.Get()
user := rs.userDrop.Get()
// store the current checked out branch name and version
rs.checkCurrentBranchName()
out := rs.pb.GetCurrentVersion()
rs.currentVersion.SetValue(out)
// rs.CheckDirty() this runs
log.Log(WARN, "")
log.Log(WARN, "checkoutBranch", master)
rs.checkoutBranch("master", master)
log.Log(WARN, "")
log.Log(WARN, "checkoutBranch", devel)
rs.checkoutBranch("devel", devel)
log.Log(WARN, "")
log.Log(WARN, "checkoutBranch", user)
rs.checkoutBranch("user", user)
// read in the tags
// rs.populateTags()
rs.recommend()
})
rs.setSpeed(duration)
log.Log(WARN, "Update() END")
// record if the repo is dirty
pb.CheckDirty()
// display the last tag version
name := rs.pb.GetLastTagVersion()
rs.lasttag.SetText(name)
// store the master branch version
ver := pb.GetMasterVersion()
rs.mainBranchVersion.SetValue(ver)
rs.develBranchVersion.SetValue(pb.GetDevelVersion())
rs.userBranchVersion.SetValue(pb.GetUserVersion())
// populates a string into the rs.gitState widget
// todo: make the values from this function a bit cleaner
rs.CheckGitState()
}
func (rs *RepoStatus) setSpeed(duration time.Duration) {
s := fmt.Sprint(duration)
if rs.speedActual == nil {
log.Log(WARN, "can't actually warn")
return
}
rs.speedActual.Set(s)
if (duration > 500 * time.Millisecond ) {
rs.speed.Set("SLOW")
} else if (duration > 100 * time.Millisecond ) {
rs.speed.Set("OK")
} else {
rs.speed.Set("FAST")
}
}
// disable all things besides Update() button
func (rs *RepoStatus) DisableEverything() {
log.Warn("DisableEverything()")
// choosing a major, minor or revision
rs.major.Disable()
rs.minor.Disable()
rs.revision.Disable()
// disable adding a tag message
rs.versionMessage.Disable()
// disable the merge devel to master button
rs.develMerge.Disable()
// disable the tag a new version button
rs.releaseVersion.Disable()
}
// this means devel needs to be merged to master
func (rs *RepoStatus) EnableMergeDevel() {
rs.DisableEverything()
rs.develMerge.Enable()
}
// this means you need to release a new version of the master repository
func (rs *RepoStatus) EnableSelectTag() {
rs.DisableEverything()
// choosing a major, minor or revision
rs.major.Enable()
rs.minor.Enable()
rs.revision.Enable()
// disable adding a tag message
rs.versionMessage.Enable()
// force there to be a commit message
rs.releaseVersion.Disable()
func (rs *RepoStatus) CheckGitState() string {
state := rs.pb.GetState()
rs.gitState.SetText(state)
return state
}

127
windowBranches.go Normal file
View File

@ -0,0 +1,127 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
"go.wit.com/gui"
)
type repoBranchesWindow struct {
repo *gitpb.Repo // the repo protobuf
win *gadgets.BasicWindow // the patches window
stack *gui.Node // the top box set as vertical
//shelf *gui.Node // the first box in the stack, set as horizontal
//grid *gui.Node // the list of available patches
//setgrid *gui.Node // the list of each patchset
}
// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow
// is the window hidden right now?
func (w *repoBranchesWindow) Hidden() bool {
return w.win.Hidden()
}
// switches between the window being visable or hidden on the desktop
func (w *repoBranchesWindow) Toggle() {
if w.Hidden() {
w.Show()
} else {
w.Hide()
}
}
// hides the window completely
func (w *repoBranchesWindow) Show() {
w.win.Show()
}
func (w *repoBranchesWindow) Hide() {
w.win.Hide()
}
// should be the first box/widget in the window
// greys out the window to the user
func (w *repoBranchesWindow) Disable() {
w.stack.Disable()
}
func (w *repoBranchesWindow) Enable() {
w.stack.Enable()
}
// you can only have one of these
func MakeRepoBranchesWindow(repo *gitpb.Repo) *repoBranchesWindow {
pw := new(repoBranchesWindow)
// sync.Once()
pw.win = gadgets.RawBasicWindow("Branches for " + repo.GetGoPath())
pw.win.Make()
pw.stack = pw.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
pw.win.Custom = func() {
log.Info("Got close. setting win.Hide()")
// sets the hidden flag to false so Toggle() works
pw.win.Hide()
}
grid := pw.stack.NewGrid("", 0, 0)
grid.NewGroup("Branches")
grid.NextRow()
grid.NewGroup("Name")
grid.NewGroup("Forge use")
grid.NewGroup("Ref Version")
grid.NewGroup("Type")
grid.NewGroup("Hash")
grid.NextRow()
/*
for _, b := range repo.GetLocalBranches() {
hash := repo.GetBranchHash(b)
grid.NewLabel(b)
grid.NewLabel(repo.GetBranchVersion(b))
if s, err := repo.GetHashName(hash); err == nil {
grid.NewLabel(s)
} else {
grid.NewLabel("err")
}
grid.NewLabel("local")
grid.NewLabel(hash)
grid.NewButton("Delete", func() {
repo.RunVerbose([]string{"git", "branch", "-D", b})
})
grid.NextRow()
}
for _, b := range repo.GetRemoteBranches() {
hash := repo.GetBranchHash(b)
grid.NewLabel(b)
forgeuse := repo.GetBranchVersion(b)
grid.NewLabel(forgeuse)
if s, err := repo.GetHashName(hash); err == nil {
grid.NewLabel(s)
} else {
grid.NewLabel("")
}
grid.NewLabel("remote")
grid.NewLabel(hash)
if b == "origin/HEAD" || forgeuse == "remote master" {
// can't delete these
} else {
grid.NewButton("Delete Remote", func() {
})
}
grid.NextRow()
}
*/
return pw
}

62
windowMain.go Normal file
View File

@ -0,0 +1,62 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
var windowMap map[string]*RepoStatus
func init() {
windowMap = make(map[string]*RepoStatus)
}
// makes a window of the status of the repo
// don't worry, you can think of it like Sierpinski carpet
// it's doesn't need to be displayed so it'll work fine even in an embedded space
func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
path := repo.GetGoPath()
if windowMap[path] == nil {
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else {
log.Warn("This already exists for path", path)
log.Warn("should return windowMap[path] here")
return windowMap[path], nil
}
rs := &RepoStatus{
ready: false,
}
rs.pb = repo
// realpath := repo.FullPath
// isGoLang := true
// rs.tags = make(map[string]string)
rs.window = gadgets.RawBasicWindow("GO Repo Details " + path)
rs.window.Horizontal()
rs.window.Make()
basebox := rs.window.Box()
group := basebox.NewGroup("stuff")
primarybox := group.Box()
primarybox.Horizontal()
// box2 := group.Box()
rs.ready = true
rs.window.Custom = func() {
rs.Hide()
log.Warn("repostatus user closed the window()")
}
// display the status of the git repository
rs.drawGitStatus(primarybox)
// display the git branches and options
rs.makeBranchesBox(primarybox)
// var win *gadgets.BasicWindow
// show standard git commit and merge controls
rs.drawGitCommands(primarybox)
windowMap[path] = rs
return rs, nil
}

216
windowMerge.go Normal file
View File

@ -0,0 +1,216 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
"go.wit.com/gui"
)
type repoMergeWindow struct {
repo *gitpb.Repo // the repo protobuf
win *gadgets.BasicWindow // the patches window
stack *gui.Node // the top box set as vertical
lasttag *gadgets.OneLiner // the last tag version
mainBranchVersion *gadgets.OneLiner // the primary branch version
develBranchVersion *gadgets.OneLiner // the devel branch version
userBranchVersion *gadgets.OneLiner // the user branch version
currentVersion *gadgets.OneLiner // the devel branch version
currentBranch *gadgets.OneLiner // the user branch version
mergeD *gui.Node // the merge button
mergeM *gui.Node // the merge button
}
// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow
// is the window hidden right now?
func (w *repoMergeWindow) Hidden() bool {
return w.win.Hidden()
}
// switches between the window being visable or hidden on the desktop
func (w *repoMergeWindow) Toggle() {
if w.Hidden() {
w.Show()
} else {
w.Hide()
}
}
// hides the window completely
func (w *repoMergeWindow) Show() {
w.win.Show()
w.Update()
}
func (w *repoMergeWindow) Hide() {
w.win.Hide()
}
// should be the first box/widget in the window
// greys out the window to the user
func (w *repoMergeWindow) Disable() {
w.stack.Disable()
}
func (w *repoMergeWindow) Enable() {
w.stack.Enable()
}
func (w *repoMergeWindow) Update() {
w.lasttag.SetText(w.repo.GetLastTag())
w.mainBranchVersion.SetText(w.repo.GetMasterVersion())
w.develBranchVersion.SetText(w.repo.GetDevelVersion())
w.userBranchVersion.SetText(w.repo.GetUserVersion())
w.currentBranch.SetText(w.repo.GetCurrentBranchName())
w.currentVersion.SetText(w.repo.GetCurrentVersion())
if w.repo.GetCurrentBranchName() == w.repo.GetDevelBranchName() {
w.mergeD.Enable()
} else {
w.mergeD.Disable()
}
if w.repo.GetCurrentBranchName() == w.repo.GetMasterBranchName() {
w.mergeM.Enable()
} else {
w.mergeM.Disable()
}
}
func (rs *RepoStatus) MakeRepoMergeWindow(repo *gitpb.Repo) *repoMergeWindow {
w := new(repoMergeWindow)
w.repo = repo
// sync.Once()
w.win = gadgets.RawBasicWindow("Merge controls for " + repo.GetGoPath())
w.win.Make()
w.stack = w.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
w.win.Custom = func() {
log.Info("Got close. setting win.Hide()")
// sets the hidden flag to false so Toggle() works
w.win.Hide()
}
grid := w.stack.NewGrid("", 0, 0)
grid.NewGroup("Merge Options")
grid.NextRow()
grid.NewButton("checkout user", func() {
w.Disable()
defer w.Enable()
if err := repo.CheckoutUser(); err != nil {
log.Info(repo.GetFullPath(), err)
}
w.repo.Reload()
w.Update()
})
grid.NextRow()
grid.NewButton("checkout devel", func() {
w.Disable()
defer w.Enable()
repo.CheckoutDevel()
w.repo.Reload()
w.Update()
})
w.mergeD = grid.NewButton("merge to devel", func() {
w.Disable()
defer w.Enable()
log.Info("repo:", repo.GetGoPath())
if result, err := repo.MergeToDevel(); err == nil {
log.Warn("THINGS SEEM OK", repo.GetFullPath())
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
} else {
log.Warn("THINGS FAILED ", repo.GetFullPath())
log.Warn("err", err)
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
}
w.repo.Reload()
w.Update()
})
grid.NextRow()
grid.NewButton("checkout master", func() {
w.Disable()
defer w.Enable()
repo.CheckoutMaster()
w.repo.Reload()
w.Update()
})
w.mergeM = grid.NewButton("merge to master", func() {
w.Disable()
defer w.Enable()
log.Info("repo:", repo.GetGoPath())
if result, err := repo.MergeToMaster(); err == nil {
log.Warn("THINGS SEEM OK", repo.GetFullPath())
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
} else {
log.Warn("THINGS FAILED ", repo.GetFullPath())
log.Warn("err", err)
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
}
w.repo.Reload()
w.Update()
})
grid.NextRow()
w.lasttag = gadgets.NewOneLiner(grid, "last tag") // `progname:"LASTTAG"`
grid.NextRow()
w.mainBranchVersion = gadgets.NewOneLiner(grid, "master") // `progname:"MASTERBRANCH"`
grid.NextRow()
w.develBranchVersion = gadgets.NewOneLiner(grid, "devel") // `progname:"DEVELBRANCH"`
grid.NextRow()
w.userBranchVersion = gadgets.NewOneLiner(grid, "user") // `progname:"USERBRANCH"`
grid.NextRow()
w.currentBranch = gadgets.NewOneLiner(grid, "current branch") // `progname:"CURRENTBRANCH"`
grid.NextRow()
w.currentVersion = gadgets.NewOneLiner(grid, "current version") // `progname:"CURRENTVERSION"`
grid.NextRow()
w.Update()
return w
}
/*
rs.showBranchesButton = newgrid.NewButton("find user and devel", func() {
log.Info("redo this")
})
newgrid.NextRow()
rs.checkBranchesButton = newgrid.NewButton("CheckBranches()", func() {
log.Info("redo this")
})
newgrid.NextRow()
newgrid.NewButton("Revert master to devel", func() {
log.Info("redo this")
})
*/

123
windowModify.go Normal file
View File

@ -0,0 +1,123 @@
package repostatus
import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
func (rs *RepoStatus) drawGitCommands(box *gui.Node) {
rs.gitCommandsGroup = box.NewGroup("modify")
newgrid := rs.gitCommandsGroup.NewGrid("gridnuts", 0, 0)
newgrid.NewButton("Rescan Repo", func() {
rs.Update()
})
newgrid.NewButton("CheckDirty()", func() {
if rs.pb.CheckDirty() {
log.Log(WARN, "is dirty")
} else {
log.Log(WARN, "is not dirty")
}
})
newgrid.NewButton("show .git/config", func() {
if rs.pb.GitConfig == nil {
log.Log(WARN, "Nonexistant or damaged .git/config", rs.Path())
return
}
log.Log(WARN, ".git/config:", rs.realPath.String())
// The info:
for name, remote := range rs.pb.GitConfig.Remotes {
log.Log(WARN, " ", name, "url:", remote.Url)
}
for name, branch := range rs.pb.GitConfig.Branches {
log.Log(WARN, " ", name, "remote:", branch.Remote, "merge", branch.Merge)
}
})
newgrid.NextRow()
newgrid.NewButton("git pull", func() {
rs.pb.GitPull()
})
newgrid.NextRow()
label := "merge " + rs.userWorkingName.String() + " to " + rs.develWorkingName.String()
rs.develMergeB = newgrid.NewButton(label, func() {
rs.Disable()
if result, err := rs.pb.MergeToDevel(); err == nil {
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else {
log.Warn("THINGS FAILED fullAutomation() returned false", result.Error)
}
rs.Enable()
})
label = "merge " + rs.develWorkingName.String() + " to " + rs.mainWorkingName.String()
rs.mainMergeB = newgrid.NewButton(label, func() {
rs.Disable()
if result, err := rs.pb.MergeToMaster(); err == nil {
log.Warn("THINGS SEEM OK fullAutomation() returned true.")
} else {
log.Warn("THINGS FAILED fullAutomation() returned false", result.Error)
}
rs.Enable()
})
newgrid.NewButton("increment version", func() {
log.Info("broken")
// rs.IncrementVersion()
})
newgrid.NextRow()
rs.major = gadgets.NewBasicCombobox(newgrid, "major")
rs.major.Custom = func() {
// rs.setTag()
// rs.generateCmd()
}
// rs.major.Hide()
newgrid.NextRow()
rs.minor = gadgets.NewBasicCombobox(newgrid, "minor")
rs.minor.Custom = func() {
// rs.setTag()
// rs.generateCmd()
}
// rs.minor.Hide()
newgrid.NextRow()
rs.revision = gadgets.NewBasicCombobox(newgrid, "revision")
rs.revision.Custom = func() {
// rs.setTag()
// rs.generateCmd()
}
// rs.revision.Hide()
newgrid.NextRow()
// newgrid.NewLabel("new tag version")
rs.newversion = newgrid.NewLabel("0.0.1")
// rs.newversion.Hide()
newgrid.NextRow()
rs.versionMessage = gadgets.NewBasicEntry(newgrid, "tag message")
rs.versionMessage.Custom = func() {
// rs.generateCmd()
}
// rs.versionMessage.Hide()
newgrid.NextRow()
rs.versionCmdOutput = gadgets.NewOneLiner(newgrid, "tag cmd")
// rs.versionCmdOutput.Hide()
newgrid.NextRow()
rs.releaseVersion = newgrid.NewButton("tag and release new version", func() {
rs.Disable()
rs.pb.MergeToMaster()
})
// rs.releaseVersion.Hide()
newgrid.NextRow()
newgrid.Margin()
newgrid.Pad()
}

73
windowRepo.go Normal file
View File

@ -0,0 +1,73 @@
package repostatus
import (
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/gui"
)
type repoWindow struct {
repo *gitpb.Repo // the repo protobuf
win *gadgets.BasicWindow // the patches window
stack *gui.Node // the top box set as vertical
//shelf *gui.Node // the first box in the stack, set as horizontal
//grid *gui.Node // the list of available patches
//setgrid *gui.Node // the list of each patchset
}
// todo: autogenerate these or make them standared 'gui' package functions
// make this an go interface somehow
// is the window hidden right now?
func (w *repoWindow) Hidden() bool {
return w.win.Hidden()
}
// switches between the window being visable or hidden on the desktop
func (w *repoWindow) Toggle() {
if w.Hidden() {
w.Show()
} else {
w.Hide()
}
}
// hides the window completely
func (w *repoWindow) Show() {
w.win.Show()
}
func (w *repoWindow) Hide() {
w.win.Hide()
}
// should be the first box/widget in the window
// greys out the window to the user
func (w *repoWindow) Disable() {
w.stack.Disable()
}
func (w *repoWindow) Enable() {
w.stack.Enable()
}
// you can only have one of these
func MakeRepoWindow(repo *gitpb.Repo) *repoWindow {
pw := new(repoWindow)
// sync.Once()
pw.win = gadgets.RawBasicWindow("Patcheset for " + repo.GetGoPath())
pw.win.Make()
pw.stack = pw.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
pw.win.Custom = func() {
// sets the hidden flag to false so Toggle() works
pw.win.Hide()
}
// grid := pw.stack.NewGrid("", 0, 0)
return pw
}