Skip to content
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

#173: use force update mode for ide-urls #155

Merged
merged 57 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4021e08
#6: fixed git pull hangs
jan-vcapgemini Dec 12, 2023
20172d5
#6: moved urls git url to constant
jan-vcapgemini Dec 12, 2023
3ea78c0
#6: added some cleanups
jan-vcapgemini Dec 12, 2023
bfba3f7
Merge branch 'main' into fix/6-git-pull-hangs
hohwille Dec 15, 2023
7f9b949
Update cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeCon…
jan-vcapgemini Jan 8, 2024
097d2f7
Update cli/src/main/java/com/devonfw/tools/ide/context/AbstractIdeCon…
jan-vcapgemini Jan 8, 2024
512a367
#6: implemented requested changes
jan-vcapgemini Jan 8, 2024
5b4d856
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 8, 2024
36383e9
Merge branch 'main' into fix/6-git-pull-hangs
hohwille Jan 8, 2024
d46ec7b
#6: fixed git fetch and reset
jan-vcapgemini Jan 9, 2024
86e874f
#6: adjusted warning
jan-vcapgemini Jan 9, 2024
2d7792a
#6: re-added git pull
jan-vcapgemini Jan 9, 2024
21347a5
#6: removed invalid interactive option
jan-vcapgemini Jan 9, 2024
22936b9
#6: fixed git pull
jan-vcapgemini Jan 9, 2024
198c66c
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 11, 2024
2763a73
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 22, 2024
ac711b9
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 23, 2024
0826be3
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 23, 2024
6cc8b14
#173: added more git checks
jan-vcapgemini Jan 23, 2024
a04db03
#173: introduced git utils
jan-vcapgemini Jan 25, 2024
49733fc
#173: more refactorings
jan-vcapgemini Jan 26, 2024
4dc4437
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 26, 2024
ef9ae80
#173: more refactorings
jan-vcapgemini Jan 29, 2024
3d4f63a
#173: added/improved warnings
jan-vcapgemini Jan 29, 2024
e862aac
#173: applied non star imports
jan-vcapgemini Jan 30, 2024
391e9f9
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Jan 31, 2024
057b495
#173: replaced isOnline
jan-vcapgemini Feb 2, 2024
43f96c8
#173: implemented requested change
jan-vcapgemini Feb 2, 2024
cccc2e7
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Feb 2, 2024
bdab005
#173: added new tests and mocks
jan-vcapgemini Feb 5, 2024
dbe5000
#173: added info messages
jan-vcapgemini Feb 5, 2024
f0de981
#173: changed to debug mode
jan-vcapgemini Feb 5, 2024
89bb42e
#173: changed to sysout
jan-vcapgemini Feb 5, 2024
f337621
#173: replaced try with assertThrows
jan-vcapgemini Feb 5, 2024
664f5f8
#173: disabled throw exception test
jan-vcapgemini Feb 5, 2024
2d98ad0
#173: implemented tempDir
jan-vcapgemini Feb 6, 2024
701df78
#173: fixed offline simulation
jan-vcapgemini Feb 9, 2024
e3ac7ab
#173: added git reset test
jan-vcapgemini Feb 9, 2024
10f09e1
#173: cleanup
jan-vcapgemini Feb 9, 2024
ef70b06
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Feb 13, 2024
d5da12e
#173: fixed issues after merge
jan-vcapgemini Feb 13, 2024
b520ddc
#173: refactored AbstractIdeContext
jan-vcapgemini Feb 13, 2024
a9f5b68
#173: new GitContext interface
jan-vcapgemini Feb 14, 2024
b1b62bc
#173: more refactorings
jan-vcapgemini Feb 15, 2024
e914e81
#173: more refactorings
jan-vcapgemini Feb 15, 2024
cf77e70
#173: deleted GitUtils
jan-vcapgemini Feb 15, 2024
0d5bb39
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Feb 15, 2024
84760ce
#173: fixed git pull hangs #6
jan-vcapgemini Feb 16, 2024
7ebbf2f
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Feb 19, 2024
924d13a
#173: implemented requested changes
jan-vcapgemini Feb 20, 2024
51cd592
#173: fixed behind message
jan-vcapgemini Feb 20, 2024
b358885
#173: implemented requested changes
jan-vcapgemini Feb 21, 2024
ef7dc49
#173: fixed javadoc
jan-vcapgemini Feb 21, 2024
df7b883
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Feb 22, 2024
c377e10
#173: fixed merge conflict
jan-vcapgemini Feb 22, 2024
400d0d5
Merge branch 'main' into fix/6-git-pull-hangs
jan-vcapgemini Feb 23, 2024
47e9eda
Merge branch 'main' into fix/6-git-pull-hangs
hohwille Feb 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
*/
public abstract class AbstractIdeContext implements IdeContext {

private static final String IDE_URLS_GIT = "https://github.com/devonfw/ide-urls.git";

private final Map<IdeLogLevel, IdeSubLogger> loggers;

private final Path ideHome;
Expand Down Expand Up @@ -178,7 +180,6 @@ public AbstractIdeContext(IdeLogLevel minLogLevel, Function<IdeLogLevel, IdeSubL
if (Files.isDirectory(rootPath)) {
if (!ideRootPath.equals(rootPath)) {
warning("Variable IDE_ROOT is set to '{}' but for your project '{}' would have been expected.");
ideRootPath = rootPath;
}
ideRootPath = this.ideHome.getParent();
} else {
Expand Down Expand Up @@ -257,10 +258,7 @@ public String getMessageIdeHome() {
*/
public boolean isTest() {

if (isMock()) {
return true;
}
return false;
return isMock();
}

/**
Expand Down Expand Up @@ -487,7 +485,7 @@ public UrlMetadata getUrls() {

if (this.urlMetadata == null) {
if (!isTest()) {
gitPullOrClone(this.urlsPath, "https://github.com/devonfw/ide-urls.git");
gitPullOrClone(this.urlsPath, IDE_URLS_GIT, true);
}
this.urlMetadata = new UrlMetadata(this);
}
Expand Down Expand Up @@ -557,7 +555,7 @@ public boolean isOnline() {
try {
int timeout = 1000;
online = InetAddress.getByName("github.com").isReachable(timeout);
} catch (Exception e) {
} catch (Exception ignored) {

}
return online;
Expand Down Expand Up @@ -589,12 +587,11 @@ public DirectoryMerger getWorkspaceMerger() {
@Override
public ProcessContext newProcess() {

ProcessContext processContext = new ProcessContextImpl(this);
return processContext;
return new ProcessContextImpl(this);
}

@Override
public void gitPullOrClone(Path target, String gitRepoUrl) {
public void gitPullOrClone(Path target, String gitRepoUrl, boolean force) {

Objects.requireNonNull(target);
Objects.requireNonNull(gitRepoUrl);
Expand All @@ -611,7 +608,19 @@ public void gitPullOrClone(Path target, String gitRepoUrl) {
askToContinue(message);
} else {
pc.errorHandling(ProcessErrorHandling.WARNING);
result = pc.addArg("pull").run(false);
if (isOnline()) {
result = pc.addArg("fetch").addArg("origin").addArg("master").run(false);
if (!result.isSuccessful()) {
warning("Git failed to fetch from origin master");
}
}
if (force) {
result = pc.addArg("reset").addArg("--hard").addArg("HEAD~").run(false);
if (!result.isSuccessful()) {
warning("Git failed to reset to head");
}
result = pc.addArg("clean").addArg("-df").run(false);
}
if (!result.isSuccessful()) {
String message = "Failed to update git repository at " + target;
if (this.offlineMode) {
Expand Down Expand Up @@ -641,7 +650,6 @@ public void gitPullOrClone(Path target, String gitRepoUrl) {
pc.addArg("clone");
if (isQuietMode()) {
pc.addArg("-q");
} else {
}
pc.addArgs("--recursive", gitRepoUrl, "--config", "core.autocrlf=false", ".");
pc.run();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,9 @@ default void requireOnline(String purpose) {
* that will contain the ".git" subfolder.
* @param gitRepoUrl the git remote URL to clone from. May be suffixed with a hash-sign ('#') followed by the branch
* name to check-out.
* @param force boolean true enforces a git hard reset and cleanup of added files
*/
void gitPullOrClone(Path target, String gitRepoUrl);
void gitPullOrClone(Path target, String gitRepoUrl, boolean force);

/**
* @return a new {@link ProcessContext} to {@link ProcessContext#run() run} external commands.
Expand Down