<div class="gmail_extra">That&#39;s correct! A very good assessment of the situation.<br><br>Now that you have a handle on the Facet architecture, I&#39;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 -&gt; GitUtils -&gt; GitFacet -&gt; GitPlugin<br><br>~Lincoln<br><br><div class="gmail_quote">On Fri, Apr 20, 2012 at 7:10 PM, Jevgeni Zelenkov <span dir="ltr">&lt;<a href="mailto:jevgeni.zelenkov@googlemail.com" target="_blank">jevgeni.zelenkov@googlemail.com</a>&gt;</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&#39;s input (ideally). Facets can modify project&#39;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&lt;String&gt; 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>
    &lt;&lt; forge command foo is executed, some files are modified
    &gt;&gt;<br>
    <br>
    if getBranches() doesn&#39;t contain &#39;history-branch&#39;<br>
        createBranch(&quot;org.forge.history&quot;)<br>
    <br>
    if currentBranch() is not &quot;org.forge.history&quot;<br>
        changeBrach(&quot;org.forge.history&quot;)<br>
    <br>
    commit(&quot;forge command foo was executed&quot;)<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 &quot;Git Undo&quot; 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">&lt;<a href="mailto:jevgeni.zelenkov@googlemail.com" target="_blank">jevgeni.zelenkov@googlemail.com</a>&gt;</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 &quot;inspect the
          state of a<br>
          Project&quot;?<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&#39;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>
          &gt; Message: 5<br>
          &gt; Date: Fri, 20 Apr 2012 09:21:10 -0400<br>
          &gt; From: &quot;Lincoln Baxter, III&quot;&lt;<a href="mailto:lincolnbaxter@gmail.com" target="_blank">lincolnbaxter@gmail.com</a>&gt;<br>
          &gt; Subject: Re: [forge-dev] GitPlugin Facet<br>
          &gt; To: forge-dev List&lt;<a href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a>&gt;<br>
          &gt; Message-ID:<br>
          &gt;       &lt;<a href="mailto:CAEp_U4GGVD8p8hH2M5PRm6gK_MkDGtAyXzokGcm3VVz70jeX2g@mail.gmail.com" target="_blank">CAEp_U4GGVD8p8hH2M5PRm6gK_MkDGtAyXzokGcm3VVz70jeX2g@mail.gmail.com</a>&gt;<br>
          &gt; Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
          &gt;<br>
          &gt; Hey Jevgeni,<br>
          &gt;<br>
          &gt; Welcome!<br>
          &gt;<br>
          &gt; Regarding the GitFacet - I believe it&#39;s in the right
          place for the moment,<br>
          &gt; but I don&#39;t believe that the GitPlugin should be
          referencing it, since the<br>
          &gt; commands in GitPlugin could be used even without a
          Project.<br>
          &gt;<br>
          &gt; GitFacet (as the issue describes poorly) is something
          that should be usable<br>
          &gt; to inspect the state of a Project via:<br>
          &gt;<br>
          &gt; project.hasFacet(GitFacet.class)<br>
          &gt;<br>
          &gt; After that, everything else is an added benefit. It
          should probably also<br>
          &gt; perform tasks like:<br>
          &gt;<br>
          &gt; project.getFacet(GitFacet.class).getBranches()<br>
          &gt; project.getFacet(GitFacet.class).getTags()<br>
          &gt; project.getFacet(GitFacet.class).getRemotes()<br>
          &gt; project.getFacet(GitFacet.class).getStatus()<br>
          &gt;<br>
          &gt; And that&#39;s where your imagination kicks in.<br>
          &gt;<br>
          &gt; Does that make sense?<br>
          &gt;<br>
          &gt; ~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>
      &quot;Simpler is better.&quot;<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>&quot;Simpler is better.&quot;<br>
</div>