-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-165: Basic Git Extension #392
Conversation
packages/git/src/common/model.ts
Outdated
/** | ||
* Representation of an individual file change in the working directory. | ||
*/ | ||
export interface FileChange { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to prefix such common names with Git
, there is already FileChange
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we put everything into the Git
namespace?
|
||
}); | ||
|
||
async function createGit(fsRoot: string = ''): Promise<DugiteGit> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to avoid module functions and prefer class methods to be able to override them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a test, did you notice that? I mean I can, but does it make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant generally, I've seen unexported module functions in other modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for tests, it is indeed not important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Show me, and we replace it. I personally hate writing this.
when it does nothing with the class' state at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should be another class then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be even longer though :) I understand your frustration, but we don't have dependency injection for modules, but for classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense.
packages/git/src/node/dugite-git.ts
Outdated
export class DugiteGit implements Git { | ||
|
||
constructor( | ||
@inject(WorkspaceServer) private readonly workspace: WorkspaceServer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to prefer protected
over private
to allow subclasses to override and access the state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer that, we use protected then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is just a pain, for example, to work around some bugs in JDT because everything is private.
registry.registerHandler(GIT_COMMANDS.STATUS.id, { | ||
execute: (): any => { | ||
this.git.repositories().then(repositories => { | ||
const first = repositories.shift(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a global repository provider that returns the repository that is currently selected in the UI instead of always the first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, what should this command do in future?
Open the git widget?
id: 'git.status', | ||
label: 'Print Git Status' | ||
}; | ||
export const REPOSITORIES = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how this command is useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was just a placeholder command to see if the interface can be called from the browser. We will get rid of this for sure.
console.info(status); | ||
}); | ||
} else { | ||
console.info('No repositories were found.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use an ILogger
}); | ||
return undefined; | ||
}, | ||
isEnabled: () => true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should obtain the repository from the provider. if there is none it should be disabled.
import { KeybindingContext, Keybinding, KeybindingContribution, KeybindingRegistry, KeyCode, Key, Modifier } from "@theia/core/lib/common"; | ||
|
||
@injectable() | ||
export class GitKeybindingContext implements KeybindingContext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need a keybinding context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be removed.
packages/git/src/common/model.ts
Outdated
/** | ||
* Representation of an individual file change in the working directory. | ||
*/ | ||
export interface FileChange { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we put everything into the Git
namespace?
* | ||
* @param path the FS path of the root to start the discovery. | ||
*/ | ||
export async function locateRepositories(path: string): Promise<Repository[]> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async
is not used in the code
return !parts[0].length ? parts.slice(1) : parts; | ||
} | ||
|
||
// function getOrigin(repository, cb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove dead code
|
||
async function splitPath(path: string): Promise<string[]> { | ||
const parts = path.split(/(\/|\\)/); | ||
if (!parts.length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer being more explicit about length === 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is bad anyway. We need to call path.dirname()
twice.
if (!parts.length) { | ||
return parts; | ||
} | ||
// When the `path` starts with a slash, the the first part is empty string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the the
import URI from "@theia/core/lib/common/uri"; | ||
|
||
export const GIT_RESOURCE_SCHEME = 'gitrev'; | ||
|
||
export class GitResource implements Resource { | ||
|
||
protected readonly toDispose = new DisposableCollection(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove it? doesn't seem to be used
ressource | ||
.then(r => r.readContents()) | ||
.then(content => console.log(content)); | ||
// try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code should be deleted
@@ -0,0 +1,235 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
module can be removed, since it is not used.
@@ -0,0 +1,153 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbicker, I was unable to figure out where do we set the id
of the left panel, so I just add this as a comment. The problem is the following: both the Files
and the Git
has the same files
ID. So the browser tests are broken.
Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, I was wrong. I have figured out what was the problem and it is unrelated to the id
. The ID is just fine.
I tested a rebase with merge conflicts. This is fixed with 2c5b969#diff-392c37f87fa84f7102bfb5248b4837d8R72 |
Sometimes when double-clicking on a change a diff editor gets opened twice (I will take care of that). Fixed in d1412d1 |
On huge repositories, the initial load sometimes has all changes twice: solved with c78e5dd |
Also on huge repos, the initial status request takes multiple seconds. @kittaakos is looking into it We have resolved a performance issue here. The selected repository was not set properly on the frontend. |
Open diff editor, close, open again. A broken editor is shown with this in the browser:
|
(removed, since it was due to broken build) |
I do not know if it is a side-effect of something else but I had this in my console, when I have tried to open an untracked file in a "diff" editor:
|
fixed in d02890b |
Editor (not the diff one) content does not get updated after discarding all the changes:
This is a general problem and tracked here: #74 |
I will look into the windows build issue and I try to fix it. Solved via this. |
With the current state I get, the following on commit:
Fixed with aaa9e41 |
branch: this.status.branch, | ||
paths: change.uri | ||
}); | ||
const options: Git.Options.Checkout.WorkingTreeFile = { paths: change.uri }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do I not need to specify the branch from which I want to checkout? AFAIU the HEAD will be detached when I am in a conflicting rebase situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then please use treeish
. AFAIK, branch
is a treeish
.
git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>…
git checkout [-p|--patch] [<tree-ish>] [--] [<paths>…]
@@ -123,7 +164,7 @@ export class MonacoEditorProvider { | |||
} | |||
} | |||
|
|||
protected installQuickOpenService(editor: MonacoEditor): void { | |||
protected installQuickOpenService(editor: MonacoEditor | MonacoDiffEditor): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is that? As I see it is a subclass of the MonacoEditor
. Is it just some leftover code?
I got this when cloned a repository inside my workspace and double clicked on the unstaged resource in the Git tab:
#593. |
Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
The frontend can still manually fetch the available repositories from the backend. Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Signed-off-by: Jan Bicker <jan.bicker@typefox.io>
Staged flag was not included in the comparison, hence client was not notified when something was staged/unstaged. Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
…ile gets deleted Signed-off-by: Jan Bicker <jan.bicker@typefox.io>
- selection of nested repositories did not work properly. - UI: the path of a file in repository root was shown as absolute path Signed-off-by: Jan Bicker <jan.bicker@typefox.io>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Removed obsolete either type. `MDE` is a structural and nominal subtype of `ME`, so need to keep the union type in the API. Signed-off-by: Akos Kitta <kittaakos@gmail.com>
…k from akosyakov Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
Signed-off-by: Sven Efftinge <sven.efftinge@typefox.io>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
I have fixed the diff editor issue. @hexa00, please review if you have time. Thank you! cc: @svenefftinge |
Repository URIs cannot be compared via the string representation of the underlying paths, because they can differ but still, they are pointing to the same location. Signed-off-by: Akos Kitta <kittaakos@gmail.com>
Signed-off-by: Akos Kitta <kittaakos@gmail.com>
See #165