Compare commits
191 Commits
Author | SHA1 | Date |
---|---|---|
|
cfc91c8ba6 | |
|
1c8f502c1b | |
|
a72e9ce5f4 | |
|
3ab156a9c4 | |
|
fa5c6572ff | |
|
d568d5dbe4 | |
|
4484b0b84d | |
|
c079039ffe | |
|
ff91deee63 | |
|
2395a4466e | |
|
2b2de94eff | |
|
750ceaf8a1 | |
|
ac2958e559 | |
|
a15d447fbd | |
|
fcb74ce2e8 | |
|
648d3ac6b6 | |
|
f53f1256f1 | |
|
4efbead37c | |
|
4dcd9a1164 | |
|
d9a54a6c31 | |
|
9221f83aaf | |
|
e323d5920c | |
|
07e0fdc437 | |
|
669c4e082c | |
|
904a5e8568 | |
|
2ea1113c72 | |
|
05d827868e | |
|
3a53e0bd9b | |
|
93e9e4e43b | |
|
54cdb3fbec | |
|
283bd90e91 | |
|
d5c394d3c3 | |
|
b52c3c426a | |
|
c25e4dd406 | |
|
e43863e8e7 | |
|
9d13c972e4 | |
|
2866815e3c | |
|
4c46927bc7 | |
|
a1ce58e9d0 | |
|
94e98f2145 | |
|
9358005c9d | |
|
2e8a1d4793 | |
|
4ab00cce02 | |
|
a7c5499221 | |
|
009d8f3b9d | |
|
55acea0bd7 | |
|
29545d3f04 | |
|
5be028858c | |
|
6b1330d7f3 | |
|
3ce9f5f773 | |
|
44ab5deb3f | |
|
31355467a5 | |
|
e6f883a9b5 | |
|
8eb7501855 | |
|
8786690d46 | |
|
b451591006 | |
|
bf2a42ec64 | |
|
5bc1a24a69 | |
|
2ce9051921 | |
|
804acc169a | |
|
2622e90b1f | |
|
7d3e4ce84e | |
|
546ad6a842 | |
|
54367ddc72 | |
|
2cdf2c3cda | |
|
f99dc30b68 | |
|
65a94faa57 | |
|
412c84fcd9 | |
|
b2d3d13ed9 | |
|
b12bc0a9ec | |
|
4d2f68606e | |
|
035b4eb443 | |
|
fc849f6003 | |
|
9a1347c03f | |
|
b354d7dd27 | |
|
cec5e7f3b4 | |
|
ccee573364 | |
|
ddd95e9afc | |
|
2a62d23482 | |
|
28a20e0922 | |
|
5268267408 | |
|
1b65474a69 | |
|
5105bd4a99 | |
|
359ebce26e | |
|
cd5f1d9d0f | |
|
5aaf02ee3a | |
|
70e8c98b1c | |
|
2a19cd5eef | |
|
e1e81ab2bf | |
|
d16cc92286 | |
|
ae7e9ba42c | |
|
ad21d5d5db | |
|
be73f6af0e | |
|
1bafc298d3 | |
|
6a6ebf78b8 | |
|
4d1301288e | |
|
0e26f2024a | |
|
45519f2370 | |
|
6e7759f570 | |
|
f82743d487 | |
|
c7aaea4ae1 | |
|
0b4f4d7686 | |
|
bd62a89a67 | |
|
88ca40bcfa | |
|
2bc2096e84 | |
|
e6eb92845a | |
|
3d6002b055 | |
|
73d711ad2b | |
|
d7e391fed0 | |
|
a223e9f1c3 | |
|
07a60ffe3c | |
|
f7947b08b6 | |
|
95fd6ca05a | |
|
d7a0246af9 | |
|
e7a3ef1298 | |
|
b4a571fb70 | |
|
ba4051cb0c | |
|
2b172338f6 | |
|
b694fc2fe2 | |
|
35e03959ab | |
|
49724b16e8 | |
|
678d6357b1 | |
|
309cf80e16 | |
|
abb1f0ea21 | |
|
118825e7a3 | |
|
3937902a7d | |
|
08b122ea2c | |
|
4d665387fe | |
|
dbf10cddf7 | |
|
fae78b1812 | |
|
1fda646fef | |
|
78049e664d | |
|
940096ff40 | |
|
ca09e7cf47 | |
|
a05f6c35ce | |
|
7e7dbebcee | |
|
408a400e93 | |
|
856b479edb | |
|
7bcbca3fce | |
|
e6cb846ccf | |
|
318b748509 | |
|
6d8a49d432 | |
|
386125826f | |
|
9147079092 | |
|
2723e53396 | |
|
9f26bc2d44 | |
|
2aed84cf3a | |
|
45e7aab862 | |
|
a80347531e | |
|
86136ce615 | |
|
4beeb0bb13 | |
|
21546ce2c0 | |
|
732ac4b1e5 | |
|
3c3dc5309a | |
|
7c82f918aa | |
|
edf74e160e | |
|
dae15b5931 | |
|
2f4cba36dd | |
|
294119e7c2 | |
|
7546209d24 | |
|
696b58744c | |
|
a9a42d5cd8 | |
|
ca5007fa87 | |
|
7a05ee53ab | |
|
e3cc044efc | |
|
e7257a919d | |
|
7a283a1da6 | |
|
39da8e6810 | |
|
d3807e5f13 | |
|
db3d481c5f | |
|
8e9e19a14f | |
|
940b1d8b6e | |
|
1d2dacab26 | |
|
e741567fef | |
|
623b35629b | |
|
ff3a51f354 | |
|
47a665be8b | |
|
2f222b0bd7 | |
|
cf3d56475d | |
|
78a3adeb15 | |
|
c65dd45ba5 | |
|
b2c21e8c16 | |
|
269ff54715 | |
|
ceaab24e56 | |
|
ba825e7eb0 | |
|
de5f84717f | |
|
784536b18a | |
|
09362840e9 | |
|
069e2421c8 | |
|
69957aadfc | |
|
4e19ff9946 |
|
@ -0,0 +1,3 @@
|
||||||
|
*.swp
|
||||||
|
go.mod
|
||||||
|
go.sum
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
14
Makefile
14
Makefile
|
@ -1,11 +1,15 @@
|
||||||
all:
|
all: goimports
|
||||||
@echo
|
GO111MODULE=off go vet
|
||||||
@echo Run: make redomod
|
|
||||||
@echo
|
goimports:
|
||||||
@# ./myrepos >/tmp/myrepos.stderr 2>&1
|
goimports -w *.go
|
||||||
|
|
||||||
redomod:
|
redomod:
|
||||||
rm -f go.*
|
rm -f go.*
|
||||||
|
goimports -w *.go
|
||||||
GO111MODULE= go mod init
|
GO111MODULE= go mod init
|
||||||
GO111MODULE= go mod tidy
|
GO111MODULE= go mod tidy
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f go.*
|
||||||
|
go-mod-clean --purge
|
||||||
|
|
25
args.go
25
args.go
|
@ -4,29 +4,28 @@ package repostatus
|
||||||
this enables command line options from other packages like 'gui' and 'log'
|
this enables command line options from other packages like 'gui' and 'log'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var NOW *log.LogFlag
|
|
||||||
var INFO *log.LogFlag
|
var INFO *log.LogFlag
|
||||||
|
|
||||||
var SPEW *log.LogFlag
|
|
||||||
var WARN *log.LogFlag
|
var WARN *log.LogFlag
|
||||||
|
|
||||||
var CHANGE *log.LogFlag
|
var CHANGE *log.LogFlag
|
||||||
var STATUS *log.LogFlag
|
|
||||||
|
var REPO *log.LogFlag
|
||||||
|
var REPOWARN *log.LogFlag
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
full := "go.wit.com/gui/gadgets/repostatus"
|
full := "go.wit.com/lib/gui/repostatus"
|
||||||
short := "repostatus"
|
short := "repostatus"
|
||||||
|
|
||||||
NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
|
INFO = log.NewFlag("INFO", false, full, short, "general repo things")
|
||||||
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
||||||
|
CHANGE = log.NewFlag("CHANGE", true, full, short, "when repo changes")
|
||||||
|
|
||||||
WARN = log.NewFlag("WARN", true, full, short, "bad things")
|
full = "go.wit.com/lib/gui/repo"
|
||||||
SPEW = log.NewFlag("SPEW", false, full, short, "spew stuff")
|
short = "repo"
|
||||||
|
|
||||||
CHANGE = log.NewFlag("CHANGE", true, full, short, "when repo changes")
|
REPO = log.NewFlag("REPO", false, full, short, "general repo things")
|
||||||
STATUS = log.NewFlag("STATUS", false, full, short, "current status")
|
REPOWARN = log.NewFlag("REPOWARN", true, full, short, "repo warnings")
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
}
|
140
common.go
140
common.go
|
@ -1,73 +1,52 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// reports externally if something has changed
|
// reports externally if something has changed
|
||||||
// since the last time it was asked about it
|
// since the last time it was asked about it
|
||||||
func (rs *RepoStatus) Changed() bool {
|
func (rs *RepoStatus) Changed() (string, bool) {
|
||||||
if ! rs.Ready() {return false}
|
if !rs.Ready() {
|
||||||
if rs.changed {
|
return "", false
|
||||||
rs.changed = false
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
return false
|
|
||||||
|
return rs.getChanges(), rs.changed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Make() {
|
// keeps a human readable list of things that have
|
||||||
if ! rs.Ready() {return}
|
// changed. todo: timestampe these?
|
||||||
log.Log(CHANGE, "Make() window ready =", rs.ready)
|
func (rs *RepoStatus) getChanges() string {
|
||||||
rs.window.Make()
|
return rs.changes
|
||||||
rs.ready = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Make2() {
|
func (rs *RepoStatus) NoteChange(s string) {
|
||||||
if ! rs.Ready() {return}
|
rs.changed = true
|
||||||
log.Log(CHANGE, "Make() window ready =", rs.ready)
|
rs.changes += s + "\n"
|
||||||
rs.window.Make()
|
|
||||||
rs.ready = true
|
|
||||||
draw(rs)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) TestDraw() {
|
|
||||||
if ! rs.Ready() {return}
|
|
||||||
log.Log(CHANGE, "TestDraw() RUNNING HERE")
|
|
||||||
rs.window.TestDraw()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) Draw() {
|
|
||||||
if ! rs.Ready() {return}
|
|
||||||
log.Log(CHANGE, "Draw() window ready =", rs.ready)
|
|
||||||
rs.window.Draw()
|
|
||||||
rs.ready = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) Draw2() {
|
|
||||||
if ! rs.Ready() {return}
|
|
||||||
log.Log(CHANGE, "draw(rs) ready =", rs.ready)
|
|
||||||
draw(rs)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Show() {
|
func (rs *RepoStatus) Show() {
|
||||||
if ! rs.Ready() {return}
|
if !rs.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Show() window ready =", rs.ready)
|
log.Log(CHANGE, "Show() window ready =", rs.ready)
|
||||||
rs.window.Show()
|
rs.window.Show()
|
||||||
rs.hidden = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Hide() {
|
func (rs *RepoStatus) Hide() {
|
||||||
if ! rs.Ready() {return}
|
if !rs.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Hide() window ready =", rs.ready)
|
log.Log(CHANGE, "Hide() window ready =", rs.ready)
|
||||||
rs.window.Hide()
|
rs.window.Hide()
|
||||||
rs.hidden = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Toggle() {
|
func (rs *RepoStatus) Toggle() {
|
||||||
if ! rs.Ready() {return}
|
if !rs.Ready() {
|
||||||
|
return
|
||||||
|
}
|
||||||
log.Log(CHANGE, "Toggle() window ready =", rs.ready)
|
log.Log(CHANGE, "Toggle() window ready =", rs.ready)
|
||||||
if rs.hidden {
|
if rs.window.Hidden() {
|
||||||
rs.Show()
|
rs.Show()
|
||||||
} else {
|
} else {
|
||||||
rs.Hide()
|
rs.Hide()
|
||||||
|
@ -75,35 +54,68 @@ func (rs *RepoStatus) Toggle() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Ready() bool {
|
func (rs *RepoStatus) Ready() bool {
|
||||||
log.Log(SPEW, "Ready() maybe not ready? rs =", rs)
|
if rs == nil {
|
||||||
if rs == nil {return false}
|
return false
|
||||||
if rs.window == nil {return false}
|
}
|
||||||
|
if rs.window == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return rs.ready
|
return rs.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Horizontal() {
|
// disable all things besides Update() button
|
||||||
rs.window.Horizontal()
|
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()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Vertical() {
|
// this means devel needs to be merged to master
|
||||||
rs.window.Vertical()
|
func (rs *RepoStatus) EnableMergeDevel() {
|
||||||
|
rs.DisableEverything()
|
||||||
|
|
||||||
|
rs.develMergeB.Enable()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) Initialized() bool {
|
func (rs *RepoStatus) Disable() {
|
||||||
log.Log(CHANGE, "checking Initialized()")
|
rs.window.Disable()
|
||||||
if rs == nil {return false}
|
|
||||||
if rs.parent == nil {return false}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *RepoStatus) SetParent(p *gui.Node) {
|
func (rs *RepoStatus) Enable() {
|
||||||
log.Log(CHANGE, "Attempting SetParent")
|
rs.window.Enable()
|
||||||
if rs == nil {return}
|
}
|
||||||
if rs.parent == nil {
|
|
||||||
log.Log(CHANGE, "SetParent =", p)
|
// this means you need to release a new version of the master repository
|
||||||
rs.parent = p
|
func (rs *RepoStatus) EnableSelectTag() {
|
||||||
return
|
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 {
|
} else {
|
||||||
log.Log(CHANGE, "SetParent was already set to =", rs.parent)
|
// rs.generateCmd()
|
||||||
|
rs.releaseVersion.Enable()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
421
draw.go
421
draw.go
|
@ -1,407 +1,36 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strconv"
|
"go.wit.com/gui"
|
||||||
"strings"
|
"go.wit.com/lib/gadgets"
|
||||||
|
|
||||||
"go.wit.com/log"
|
|
||||||
"go.wit.com/gui/gui"
|
|
||||||
"go.wit.com/gui/gadgets"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// creates the actual widgets.
|
func (rs *RepoStatus) drawGitStatus(box *gui.Node) {
|
||||||
// it's assumed you are always passing in a box
|
rs.gitStatusGroup = box.NewGroup("What GIT Knows It Has")
|
||||||
func draw(rs *RepoStatus) {
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// rs.masterDrop.Set(master)
|
|
||||||
// relabel the various gadgets with the right branch name
|
|
||||||
rs.masterBranchVersion.SetLabel(master)
|
|
||||||
// rs.major.SetTitle(master)
|
|
||||||
|
|
||||||
/*
|
|
||||||
rs.develDrop.Set("devel")
|
|
||||||
rs.userDrop.Set("jcarr")
|
|
||||||
*/
|
|
||||||
|
|
||||||
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")
|
|
||||||
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
|
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
|
||||||
// newgrid.SetNext(1,1)
|
|
||||||
newgrid.Margin()
|
newgrid.Margin()
|
||||||
newgrid.Pad()
|
newgrid.Pad()
|
||||||
|
|
||||||
rs.path = gadgets.NewOneLiner(newgrid, "path")
|
rs.path = gadgets.NewOneLiner(newgrid, "path")
|
||||||
rs.currentBranch = gadgets.NewOneLiner(newgrid, "branch")
|
rs.goSrcPath = gadgets.NewOneLiner(newgrid, "~/go/src")
|
||||||
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
|
rs.goPath = gadgets.NewOneLiner(newgrid, "go path")
|
||||||
rs.currentVersion = gadgets.NewOneLiner(newgrid, "Version")
|
rs.realPath = gadgets.NewOneLiner(newgrid, "full path")
|
||||||
rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "existing tags")
|
rs.isGoLang = gadgets.NewOneLiner(newgrid, "Is GO Lang?")
|
||||||
rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
|
rs.isGoLang.SetText("false")
|
||||||
rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
|
rs.mainWorkingName = gadgets.NewOneLiner(newgrid, "main working branch")
|
||||||
rs.jcarrBranchVersion = gadgets.NewOneLiner(newgrid, "jcarr")
|
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.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.speed = gadgets.NewOneLiner(newgrid, "refresh speed =")
|
||||||
rs.speedActual = gadgets.NewOneLiner(newgrid, "speed actual =")
|
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() {
|
|
||||||
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.develMerge.Disable() // don't let this run twice for now
|
|
||||||
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 == jcarr?", rs.develBranchVersion.Get(), rs.jcarrBranchVersion.Get())
|
|
||||||
if rs.develBranchVersion.Get() != rs.jcarrBranchVersion.Get() {
|
|
||||||
log.Warn("devel does not equal jcarr")
|
|
||||||
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)
|
|
||||||
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"))
|
|
||||||
}
|
}
|
||||||
|
|
236
git.go
236
git.go
|
@ -1,220 +1,42 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
// most everything here needs to be deprecated now
|
||||||
"strings"
|
func (rs *RepoStatus) Path() string {
|
||||||
"unicode/utf8"
|
return rs.realPath.String()
|
||||||
|
|
||||||
"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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
.git/refs/remotes
|
func (rs *RepoStatus) GitState() string {
|
||||||
.git/refs/remotes/github
|
return rs.gitState.String()
|
||||||
.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) getBranches() []string {
|
func (rs *RepoStatus) GetStatus() string {
|
||||||
var all []string
|
return rs.gitState.String()
|
||||||
var heads []string
|
}
|
||||||
var remotes []string
|
|
||||||
heads = listFiles(fullpath(rs.repopath + "/.git/refs/heads"))
|
|
||||||
remotes = listFiles(fullpath(rs.repopath + "/.git/refs/remotes"))
|
|
||||||
|
|
||||||
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 {
|
// stores the current branch name
|
||||||
log.Warn("getBranches()", branch)
|
func (rs *RepoStatus) checkCurrentBranchName() string {
|
||||||
|
currentname := rs.currentBranch.String()
|
||||||
|
out := rs.pb.GetCurrentBranchName()
|
||||||
|
if currentname == out {
|
||||||
|
// nothing changed
|
||||||
|
return currentname
|
||||||
}
|
}
|
||||||
return all
|
rs.currentBranch.SetValue(out)
|
||||||
}
|
if currentname == "" {
|
||||||
|
return out // don't note if there was nothing before
|
||||||
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.NoteChange("current branch has changed from " + currentname + " to " + out)
|
||||||
}
|
return out
|
||||||
|
|
||||||
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.jcarrBranchVersion.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)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (rs *RepoStatus) SetUserName(s string) {
|
|
||||||
rs.userDrop.Set(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.jcarrBranchVersion.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
|
|
||||||
}
|
}
|
||||||
|
|
16
go.mod
16
go.mod
|
@ -1,16 +0,0 @@
|
||||||
module go.wit.com/gui/gadgets/repostatus
|
|
||||||
|
|
||||||
go 1.21.4
|
|
||||||
|
|
||||||
require (
|
|
||||||
go.wit.com/gui/gadgets v0.10.3
|
|
||||||
go.wit.com/gui/gui v0.12.3
|
|
||||||
go.wit.com/log v0.5.1
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/alexflint/go-scalar v1.2.0 // indirect
|
|
||||||
go.wit.com/arg v1.4.4 // indirect
|
|
||||||
go.wit.com/gui/widget v0.0.0-20240105185907-84aafa536a93 // indirect
|
|
||||||
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 // indirect
|
|
||||||
)
|
|
23
go.sum
23
go.sum
|
@ -1,23 +0,0 @@
|
||||||
github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
|
|
||||||
github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
||||||
go.wit.com/arg v1.4.4 h1:nfW8JUsVfyXi5l3BlTq5GGhesLlnyh3ICIm8cpM2U8w=
|
|
||||||
go.wit.com/arg v1.4.4/go.mod h1:P2JoYIsJ9SSvp45qSnYibQEQPNTuTB8dTkyT9y1btsI=
|
|
||||||
go.wit.com/gui/gadgets v0.10.3 h1:sL1GULM8Aedch3kSBdm4XuYMz/TfJ+pPeha/927/pGU=
|
|
||||||
go.wit.com/gui/gadgets v0.10.3/go.mod h1:9bgxU4rUi4NQaZCgvuLvo6BwHsCx35kNyDalztYNT3A=
|
|
||||||
go.wit.com/gui/gui v0.12.3 h1:0hmW5nlfvp+XRYfc59XZG/pSe/89+tMJo12h95XH98M=
|
|
||||||
go.wit.com/gui/gui v0.12.3/go.mod h1:WrAJB4kIR/U0z/PzrkYYQG6QeuXDLcpgiH5vXnz5I1s=
|
|
||||||
go.wit.com/gui/widget v0.0.0-20240105185907-84aafa536a93 h1:zCzaHvXJJ/rWXmDc/v79VvM6W2lxxzJGfnW2lHCv3Ho=
|
|
||||||
go.wit.com/gui/widget v0.0.0-20240105185907-84aafa536a93/go.mod h1:A6/FaiFQtAHTjgo7c4FrokXe6bXX1Cowo35b2Lgi31E=
|
|
||||||
go.wit.com/log v0.5.1 h1:D1Gdpo+EIOZDnBmW2SJCmqSD30ZWTGZ++NXyXeyMd2Y=
|
|
||||||
go.wit.com/log v0.5.1/go.mod h1:0oxmE+WavwUZspnVAcOuIjS3vx7qVOFXj3vmUqKlzTE=
|
|
||||||
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 h1:UEX2EzLQPzLTfy/kUFQD7OXtvKn8wk/+jpDOkbl4ff4=
|
|
||||||
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9/go.mod h1:qBpgJXThMMT15vym7/E4Ur9y8oOo2nP7t2RP52QHUNw=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
19
new.go
19
new.go
|
@ -1,19 +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.ready = true
|
|
||||||
return rs
|
|
||||||
}
|
|
99
structs.go
99
structs.go
|
@ -1,63 +1,82 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/gui/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type RepoStatus struct {
|
type RepoStatus struct {
|
||||||
ready bool
|
ready bool
|
||||||
hidden bool
|
changed bool // keeps track of changes that might have happened
|
||||||
changed bool
|
changes string
|
||||||
|
// tags map[string]string
|
||||||
|
InitOk bool // it takes a second or so to init these
|
||||||
|
|
||||||
repopath string
|
pb *gitpb.Repo // the protobuf
|
||||||
lasttagrev string
|
|
||||||
tags map[string]string
|
|
||||||
|
|
||||||
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
|
window *gadgets.BasicWindow // the main window for this repo
|
||||||
// group *gui.Node
|
Tags *GitTagBox // a box of all the git tags
|
||||||
// grid *gui.Node
|
|
||||||
|
|
||||||
// status *gadgets.OneLiner
|
dirtyLabel *gadgets.OneLiner
|
||||||
dirtyLabel *gadgets.OneLiner
|
dirtyList string // the output from git status --porcelain
|
||||||
path *gadgets.OneLiner
|
readOnly *gadgets.OneLiner
|
||||||
|
gitState *gadgets.OneLiner
|
||||||
|
|
||||||
currentBranch *gadgets.OneLiner
|
primitive *gadgets.OneLiner // aka: doesn't have a go.sum file
|
||||||
currentVersion *gadgets.OneLiner
|
private *gadgets.OneLiner // it's not possible to publish this to pkg.go.dev
|
||||||
tagsDrop *gadgets.BasicDropdown
|
protobuf *gadgets.OneLiner // is this repo a protobuf repo?
|
||||||
|
|
||||||
lasttag *gadgets.OneLiner
|
path *gadgets.OneLiner
|
||||||
masterBranchVersion *gadgets.OneLiner
|
goSrcPath *gadgets.OneLiner
|
||||||
develBranchVersion *gadgets.OneLiner
|
goPath *gadgets.OneLiner
|
||||||
jcarrBranchVersion *gadgets.OneLiner
|
realPath *gadgets.OneLiner
|
||||||
|
isGoLang *gadgets.OneLiner
|
||||||
|
|
||||||
develMerge *gui.Node
|
currentBranch *gadgets.OneLiner
|
||||||
releaseVersion *gui.Node
|
currentVersion *gadgets.OneLiner
|
||||||
|
|
||||||
// vgroup *gui.Node
|
mainWorkingName *gadgets.OneLiner // the actual name of the primary branch
|
||||||
minor *gadgets.BasicCombobox
|
develWorkingName *gadgets.OneLiner // the actual name of the devel branch
|
||||||
major *gadgets.BasicCombobox
|
userWorkingName *gadgets.OneLiner // the actual name of the user branch
|
||||||
revision *gadgets.BasicCombobox
|
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
|
versionMessage *gadgets.BasicEntry
|
||||||
versionCmds [][]string
|
versionCmds [][]string
|
||||||
versionCmdOutput *gadgets.OneLiner
|
versionCmdOutput *gadgets.OneLiner
|
||||||
|
targetReleaseVersion *gadgets.OneLiner
|
||||||
|
|
||||||
newversion *gui.Node
|
newversion *gui.Node
|
||||||
|
|
||||||
gitBranchesGroup *gui.Node
|
gitBranchesGroup *gui.Node
|
||||||
gitStatusGroup *gui.Node
|
gitStatusGroup *gui.Node
|
||||||
gitCommandsGroup *gui.Node
|
gitCommandsGroup *gui.Node
|
||||||
|
|
||||||
masterDrop *gadgets.BasicDropdown
|
showBranchesButton *gui.Node
|
||||||
develDrop *gadgets.BasicDropdown
|
|
||||||
userDrop *gadgets.BasicDropdown
|
|
||||||
|
|
||||||
showBranchesButton *gui.Node
|
|
||||||
checkBranchesButton *gui.Node
|
checkBranchesButton *gui.Node
|
||||||
|
|
||||||
speed *gadgets.OneLiner
|
speed *gadgets.OneLiner
|
||||||
speedActual *gadgets.OneLiner
|
speedActual *gadgets.OneLiner
|
||||||
|
|
||||||
|
// gitConfig *GitConfig
|
||||||
|
// goConfig GoConfig
|
||||||
|
|
||||||
|
switchBranchB *gui.Node
|
||||||
|
targetBranch *gui.Node
|
||||||
}
|
}
|
||||||
|
|
|
@ -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())
|
||||||
|
}
|
||||||
|
}
|
17
timer.go
17
timer.go
|
@ -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
188
unix.go
|
@ -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
128
update.go
|
@ -1,119 +1,49 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (rs *RepoStatus) Update() {
|
func (rs *RepoStatus) Update() {
|
||||||
if ! rs.Ready() {
|
if !rs.Ready() {
|
||||||
log.Log(WARN, "can't update yet. ready is false")
|
log.Log(WARN, "can't update yet. ready is false")
|
||||||
log.Error(errors.New("Update() is not ready yet"))
|
log.Error(errors.New("Update() is not ready yet"))
|
||||||
return
|
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" {
|
pb := rs.pb
|
||||||
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get())
|
|
||||||
rs.DisableEverything()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
master := rs.masterDrop.Get()
|
// store the current checked out branch name and version
|
||||||
devel := rs.develDrop.Get()
|
rs.checkCurrentBranchName()
|
||||||
user := rs.userDrop.Get()
|
out := rs.pb.GetCurrentVersion()
|
||||||
|
rs.currentVersion.SetValue(out)
|
||||||
|
|
||||||
// rs.CheckDirty() this runs
|
// read in the tags
|
||||||
log.Log(WARN, "")
|
// rs.populateTags()
|
||||||
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)
|
|
||||||
|
|
||||||
rs.recommend()
|
// record if the repo is dirty
|
||||||
})
|
pb.CheckDirty()
|
||||||
rs.setSpeed(duration)
|
|
||||||
log.Log(WARN, "Update() END")
|
// 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) {
|
func (rs *RepoStatus) CheckGitState() string {
|
||||||
s := fmt.Sprint(duration)
|
state := rs.pb.GetState()
|
||||||
if rs.speedActual == nil {
|
rs.gitState.SetText(state)
|
||||||
log.Log(WARN, "can't actually warn")
|
return state
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
|
@ -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")
|
||||||
|
})
|
||||||
|
*/
|
|
@ -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()
|
||||||
|
}
|
|
@ -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
|
||||||
|
}
|
Loading…
Reference in New Issue