<div class="gmail_extra">That's correct! A very good assessment of the situation.<br><br>Now that you have a handle on the Facet architecture, I'll add one more caveat :)<br><br>To confuse things even further, I would not implement the actual JGit features in the Facet itself (even though it would be correct to do so.) I would instead create a utility class that the Facet itself would use. This utility class could be reused by plugins directly (for plugins that do not necessarily operate on a project.)<br>
<br>Does that make sense?<br><br>So you would have:<br><br>jGit -> GitUtils -> GitFacet -> GitPlugin<br><br>~Lincoln<br><br><div class="gmail_quote">On Fri, Apr 20, 2012 at 7:10 PM, Jevgeni Zelenkov <span dir="ltr"><<a href="mailto:jevgeni.zelenkov@googlemail.com" target="_blank">jevgeni.zelenkov@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
OK. I will try to rephrase you just to make sure I understood it.
GitFacet acts as a central API for the Git-related commands in a
forge project. Facet methods have dependencies on jGit but they only
accept and return objects from the standard Java API (like Strings,
Arrays, etc) this way GitFacet is the only component with jGit
dependencies. Facets neither print anything to the shell nor require
user's input (ideally). Facets can modify project's state (=files)
and return information about the project.<br>
<br>
Example. (kept simple. Will probably require some more steps in
between)<br>
To create a new commit in the the git undo branch, GitFacet should
provide at least the following methods:<br>
* public List<String> getBranches() // to see if undo-branch
exists or should be created first<br>
* public String getCurrentBranch() // to see which branch we are
currently working on<br>
* public boolean changeBranch(String newBranch) // switches to the
new branch (newBranch is provided by the undo plugin)<br>
* public boolean createBranch(String newBranch) // creates a new
branch<br>
* public boolean commit(String msg) // adds all changes from the
working tree to the index, and creates a git commit with a given
commit message (msg is provided by the undo plugin)<br>
<br>
the logic should be something like this:<br>
<< forge command foo is executed, some files are modified
>><br>
<br>
if getBranches() doesn't contain 'history-branch'<br>
createBranch("org.forge.history")<br>
<br>
if currentBranch() is not "org.forge.history"<br>
changeBrach("org.forge.history")<br>
<br>
commit("forge command foo was executed")<br>
<br>
Does that sound right?<br>
<br>
Was FORGE-183 planned as some kind of a general wrapper around jGit
to provide the most common use cases?<div><div class="h5"><br>
<br>
<br>
On 04/21/2012 12:14 AM, Lincoln Baxter, III wrote:
<blockquote type="cite">The "Git Undo" functionality would certainly use the
GitFacet, because you would only want to activate Undo support
when working on a Project.<br>
<br>
<b>Some information about Facets:</b><br>
<ul>
<li>Facets represent project state (E.g. Git is installed. Java
is installed. Servlet is installed)<br>
</li>
<li>Facets do not work outside of projects.</li>
<li>Facets avoid doing anything that prints to the shell output
(sometimes it is unavoidable)<br>
</li>
<li>Facets are for encapsulating additional functionality that
is usable in one or more plugins</li>
</ul>
<p>With that said, only some of the additional methods you
suggested are not really appropriate for a Facet:<br>
</p>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<p>- showLatestDiff()<br>
</p>
</blockquote>
<div>probably not appropriate because it would print output - this
should go into the GitPlugin instead<br>
</div>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<p>
- showLatestCommit()<br>
</p>
</blockquote>
<div>Probably not appropriate because it would print output - this
should go into the GitPlugin instead</div>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<p>
- getNotes()<br>
</p>
</blockquote>
<div>Not sure what this does. <br>
</div>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<p>
- showLog()<br>
</p>
</blockquote>
<div>
<div>Probably not appropriate because it would print output -
this should go into the GitPlugin instead</div>
</div>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<p>
- switchBranch()<br>
</p>
</blockquote>
<div>Appropriate as an API, but not if it requires user input -
this is potentially a good method and in line with being
appropriate for a Facet.</div>
<blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<p>
- cleanWorkingDirectory()</p>
</blockquote>
<div>Not exactly sure what this would do, but yes, sounds in line
with being appropriate for a Facet.<br>
</div>
<p>Does that help? :)<br>
</p>
<p>~Lincoln<br>
</p>
<div class="gmail_quote">
On Fri, Apr 20, 2012 at 4:52 PM, Jevgeni Zelenkov <span dir="ltr"><<a href="mailto:jevgeni.zelenkov@googlemail.com" target="_blank">jevgeni.zelenkov@googlemail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Lincoln,<br>
<br>
Thanks for the explanation, that helped me to understand it
but not<br>
completely. So, what do you actually mean by "inspect the
state of a<br>
Project"?<br>
<br>
I take methods provided by you:<br>
- getBranches()<br>
- getTags()<br>
- getRemotes()<br>
- getStatus()<br>
<br>
And here are some more suggestions to help inspect the state
of a project:<br>
- showLatestDiff()<br>
- showLatestCommit()<br>
- getNotes()<br>
- showLog()<br>
- switchBranch()<br>
- cleanWorkingDirectory()<br>
<br>
Would that be enough?<br>
I guess, I don't understand the use cases for the GitFacet
yet.<br>
Who is going to use it and what are the potential scenarios?
The git<br>
undo plugin will require a lot more than that. And I assume
that<br>
GitFacet is not really a wrapper for the jGit functionality.<br>
<br>
Regards,<br>
Jevgeni<br>
<br>
On 04/20/2012 06:00 PM, <a href="mailto:forge-dev-request@lists.jboss.org" target="_blank">forge-dev-request@lists.jboss.org</a>
wrote:<br>
> Message: 5<br>
> Date: Fri, 20 Apr 2012 09:21:10 -0400<br>
> From: "Lincoln Baxter, III"<<a href="mailto:lincolnbaxter@gmail.com" target="_blank">lincolnbaxter@gmail.com</a>><br>
> Subject: Re: [forge-dev] GitPlugin Facet<br>
> To: forge-dev List<<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a>><br>
> Message-ID:<br>
> <<a href="mailto:CAEp_U4GGVD8p8hH2M5PRm6gK_MkDGtAyXzokGcm3VVz70jeX2g@mail.gmail.com" target="_blank">CAEp_U4GGVD8p8hH2M5PRm6gK_MkDGtAyXzokGcm3VVz70jeX2g@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset="iso-8859-1"<br>
><br>
> Hey Jevgeni,<br>
><br>
> Welcome!<br>
><br>
> Regarding the GitFacet - I believe it's in the right
place for the moment,<br>
> but I don't believe that the GitPlugin should be
referencing it, since the<br>
> commands in GitPlugin could be used even without a
Project.<br>
><br>
> GitFacet (as the issue describes poorly) is something
that should be usable<br>
> to inspect the state of a Project via:<br>
><br>
> project.hasFacet(GitFacet.class)<br>
><br>
> After that, everything else is an added benefit. It
should probably also<br>
> perform tasks like:<br>
><br>
> project.getFacet(GitFacet.class).getBranches()<br>
> project.getFacet(GitFacet.class).getTags()<br>
> project.getFacet(GitFacet.class).getRemotes()<br>
> project.getFacet(GitFacet.class).getStatus()<br>
><br>
> And that's where your imagination kicks in.<br>
><br>
> Does that make sense?<br>
><br>
> ~Lincoln<br>
<br>
_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
Lincoln Baxter, III<br>
<a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
"Simpler is better."<br>
<br>
<fieldset></fieldset>
<br>
<pre>_______________________________________________
forge-dev mailing list
<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a>
</pre>
</blockquote>
<br>
</div></div></div>
<br>_______________________________________________<br>
forge-dev mailing list<br>
<a href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/forge-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>"Simpler is better."<br>
</div>